Date functions are used to perform a number of common calculations which frequently appear in rules. For example:
NOTE: Date and number inputs may be either constant values or variables.
Be sure to use the exact syntax for these functions including spacing and parentheses as specified below.
TIP: The localized syntax for these functions may be viewed:
Function | Example rule | Inputs |
Outputs |
---|---|---|---|
CurrentDate |
|
today's date: 2005-04-15 today's date: 2009-08-31 |
today = 2005-04-15 the date of the investigation = 2009-08-31 |
NextDayOfTheWeek |
|
the current date: 2009-08-09 |
next Monday = 10 August 2009 next Tuesday = 11 August 2009 |
PreviousDayOfTheWeek |
|
the current date: 2009-08-09 | last Thursday = 6 August 2009 |
AddDays |
|
the date of loan: 2006-01-04 |
the date that the library book must be returned by = 25 |
SubtractDays |
|
the date of the show: 2007-05-15 | the closing date for the entry = 2007-05-05 |
AddWeeks |
|
the date that the event begins: 2001-08-13 the number of weeks in the event: 12 |
the date that the event finishes = 2001-11-05 |
SubtractWeeks |
|
the end date of the promotion: 2008-12-24 | the start date of the 5 week promotion = 2008-11-19 |
AddMonths |
|
the date of the suspension: 2005-12-12 |
the date that the player can return from suspension = 2006-03-12 |
SubtractMonths |
|
the end date of the player's contract: 2006-06-30 | the start date of the player's 12 month contract = 2005-06-30 |
AddYears |
|
the date of the crime: 2002-01-01 |
the date of the trial = 2005-01-01 |
SubtractYears |
|
the date that the prison sentence ends: 1980-03-16 | the date that the prison sentence starts = 1960-03-16 |
WeekdayCount |
|
date1: 2007-12-03; date2: 2007-12-13 date1: 2007-10-15; date2: 2007-10-31 |
the number of working days until my holiday = 8 the number of business days in the specified period = 12 |
YearStart |
|
the date of the grand occasion: 2007-09-09 |
the start of the first relevant year = 2009-01-01 the start of the second relevant year = 2007-01-01 |
YearEnd |
|
the relevant date: 2005-10-15 | the end of the relevant year = 2005-12-31 |
DayDifference |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 13 |
DayDifferenceInclusive |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 14 |
DayDifferenceExclusive |
|
date1: 2006-10-01 date2: 2006-10-14 |
the number of days in the assessment period = 12 |
WeekDifference |
|
the current date: 2006-07-19 the expiry date: 2006-08-22 |
the number of weeks remaining = 4 |
MonthDifference |
|
the current date: 2006-07-19 the expiry date: 2006-12-25 |
the number of months remaining = 5 |
YearDifference |
|
the date the tree was planted: 2000-03-12 the date the tree was assessed: 2003-12-12 |
the age of the tree in years = 3 |
YearDifference (inclusive) |
|
the date the tree was planted: 2000-03-12 the date the tree was assessed: 2003-12-12 |
the age of the tree in years = 4 |
MakeDate |
|
yyyy: 2006; mm: 10; dd: 19 |
the calculation date = 2006-10-19 |
ExtractDay |
|
the use-by date on the packet: 2008-06-12 | the day of expiry = 12 |
ExtractMonth |
|
the use-by date on the packet: 2007-04-16 | the month of expiry = 04 |
ExtractYear |
|
the use-by date on the packet: 2009-02-21 | the year of expiry = 2009 |
NextDate |
|
the test date: 2005-07-02 |
the end of the Australian tax year = 2006-06-30 |
UKNextTaxYearDates |
|
the test date: 2003-09-21 |
the date of effect = 2004-04-05 |
UKPreviousTaxYearDates |
|
the test date: 2003-09-21 | the assessment date = 2003-04-06 |
Latest (uses the Maximum function) |
|
the first Monday in May: 2001-05-05 the July event date: 2008-07-05; the December event date: 2008-12-25 |
the last date to sign up = 2001-05-05 the most recent event date = 2008-12-25 |
Earliest (uses the Minimum function) |
|
the date on which Fred played golf: 2002-10-11 the start date of the annual leave = 2008-10-27 |
the first round of golf date = 2002-10-10 the earliest holiday start date = 2008-10-26 |
See also: