How Do I Increment a Date Value? (Magic xpi 3.x)
Dates in Magic xpi are stored internally as an integer representing the number of days since the year zero. So, to increment a date, you can just add some number of days to it. For instance:
Date() + 5
will return a date 5 days from now.
However, if you want to increment the date by some number of months or years, you would use the AddDate() function. It takes four parameters, as shown below:
AddDate(Date, Years, Months, Days)
|
Date
|
The base date (saved in a variable) to add/subtract from.
|
Years
|
Number of years to add or subtract.
|
Months
|
Number of months to add or subtract.
|
Days
|
Number of days to add or subtract.
|
So, if you create an expression:
AddDate(F.myDate,0,-1,0)
would subtract a month from the base date. So if you started with July 6, 2014, then the AddDate() function shown above would return June 6, 2014.