To the given date, rolls (adds or subtracts) a number of specific time
intervals, returning another date. This function assumes a standard Gregorian
@DATEROLL ( date, date_part, index )
|date||A number representing the date between January 1, 1970 and Dec 31, 2037.
The number is the number of seconds elapsed since midnight, January 1, 1970.
To retrieve this number, use either of the following functions: @TODAY, @TODATEEX.
Date-time attribute properties of a member can also be used to retrieve
|date_part||Defined using the following rule:
date_part_ex ::= DP_YEAR | DP_QUARTER |DP_MONTH | DP_WEEK | DP_DAY | DP_DAYOFYEAR | DP_WEEKDAY
Defined time components as per the standard calendar:
|number||Number of time intervals to add or subract.|
Based on input date_part and dateroll number, the date is moved forward or backward in
Example: For input date June 14, 2005 and input dateroll number 5,
- DP_YEAR adds 5 years to the input date. (June 14, 2010)
- DP_QUARTER adds 5 quarters to the input date. (June 14, 2005
+ 5 quarters = June 14, 2005 + 15 months = Sept 14, 2006)
- DP_MONTH adds 5 months to the input date (June 14, 2005 +
5 months = Nov 14, 2005)
- DP_WEEK adds 5 weeks to the input date (June 14, 2005 + 5
weeks = June 14, 2005 + 35 days = July 19, 2005)
- DP_DAY adds 5 days to the input date. (June 14, 2005 + 5 days
= June 19, 2005)
Assume the outline has two date type members, MyDate1 and MyDate2.
Profit=@DateDiff(MyDate1, MyDate2, DP_WEEK); Profit=@DatePart(MyDate1, DP_YEAR); MyDate2=@DateRoll(MyDate1, DP_MONTH), 10);