How Do I Increment a Date Value? (Magic xpa 4.x)
Dates in Magic xpa 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 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(B,0,-1,0)
Would subtract a month from the base date. So if you started with July 6, 2008, then the AddDate() function shown above would return June 6, 2008.
The Online and Rich Client Samples projects (program DT04 and RDT04)