Rules for Date Expressions
The following are basic rules for date expressions. It is always recommended that date expressions be evaluated to determine if the desired value is attained.
- When using YEAR as a Date Unit, the same date in the calculated year is the result. For example when adding a YEAR to an absolute date like "12-dec-2011" the result is "12-dec-2007".
- The "THIS_WEEK" added to a day of the week means the day of the current week even if that is in the past. If today was Thursday then MONDAY_THIS_WEEK would be three days earlier. MONDAY by itself would be the upcoming Monday four days later.
- When using MONTH as a Date Unit, the same day of the month in the calculated month is the result. For example when adding a MONTH to an absolute date like "12-dec-2011" the result is "12-jan-2008.
- YESTERDAY and TOMORROW are calculated as the current time tomorrow or yesterday.
- BOY/BEGINNING_OF_YEAR is first day of the upcoming year.
- BOM/BEGINNING_OF_MONTH is first day of upcoming month.
- Absolute dates and Delta dates must be in quotes. Parentheses are recommended (e.g. ADATE ("NOW"))
- The default for a date unit when not using a date unit keyword is SECONDS (e.g. "NOW" + 2 would be the current time plus 2 seconds). It is recommended that date unit keywords always be used.
- Building date strings sometimes requires a casting operator. In the example below, the string "1-feb" + "2011" without casting will be interpreted as adate("1-feb") + ddate("2011"), or the date 1-Feb + 2011 hours. Casting ensures that all segments remain strings, and the '+' then causes concatenation.
Building the date string: "1-feb-2011" from the strings "1-feb" and"2011"
with cast: (( string "1-feb-" + string "2011" )
without cast: (( "1-feb-" + "2011" ))