Hi,
I am attempting to create two "dateParm"s without having to actually type both in an input box. DateParm will be an inputbox (example, i type in "20181127")
DateParm1 should always be 4 days prior to "dateParm" . How can i create a custom formula to make DateParm1 = dateParm - 4 days.
Sub Main
IgnoreWarning(True) Client.CloseAll dateParm = InputBox ("Enter Date String (YYYYMMDD): ") dateParm1 = dateParm - 4
mpine@clearbala...
Offline
Last seen: 3 years 3 months ago
Joined: 08/22/2018 - 16:11
Hi there,
In IDEAScript there is an interesting trick, all the @ functions avialable in the Equation Editor are also available in IDEAScript by changing the @ for an i. The only downside is it only works for @ functions available prior to IDEA V9 but fortunately that is most of them. So for your question you can use the @DaysToD and @DtoDays to change the date to a number, subtract 4 days and then change it back to a date. Here is some sample code for you:
Sub Main
Dim dateParm1 As String
Dim dateParm2 As String
dateParm1 = InputBox ("Enter Date String (YYYYMMDD): ")
dateParm2 = iDToDays(dateParm1) - 4
dateParm2 = iDaysToD(dateParm2 )
MsgBox "Entered date: " & dateParm1
MsgBox "Date 4 days earlier: " & dateParm2
End Sub
Thank you Brian. This has helped. However, I am still getting an error. I was hoping the msg box would show "2018-11-23"
You need to make sure your date is in the YYYYMMDD format exactly. Any other format will cause an error as this is the native IDEA format. If it is different you need to change it to the YYYYMMDD format before actually using the function.
Thank you. That helped.