To the given date, rolls (adds or subtracts) a number of specific time intervals, returning another date. This function assumes a standard Gregorian calendar.
Syntax
DateRoll ( date, date_part, number )
Parameter | Description |
---|---|
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 any of the following functions: Today(), TodateEx(), GetFirstDate(), GetLastDate(). Date-time attribute properties of a member can also be used to retrieve this number. For example,
|
date_part | Defined time components as per the standard calendar.
|
number | Number of time intervals to add or subtract. |
Notes
Based on input date_part and dateroll number, the date is moved forward or backward in time.
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)
Example
The following query returns actual weekly sales, rolling back for six months from Apr 2005 (inclusive), for the product Cola in the market California.
SELECT {[Sales]} ON COLUMNS, {DateToMember ( DateRoll( GetFirstDate ([Apr 2005]), DP_MONTH, 6 ), [Time dimension].Dimension, [Time dimension].[WEEKS] ): ClosingPeriod([Time dimension].[Weeks], [Apr 2005])) } ON ROWS FROM MySamp.Basic Where (Actual, California, Cola);