Date function rule examples

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:

Rule examples

Function Example rule Inputs

Outputs

CurrentDate

today = the current date

the date of the investigation = 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

next Monday = NextDayOfTheWeek(the current date,"Monday")

next Tuesday = the next Tuesday on or after the current date

the current date: 2009-08-09

next Monday = 10 August 2009

next Tuesday = 11 August 2009

PreviousDayOfTheWeek

last Thursday = the Thursday on or before the current date

the current date: 2009-08-09 last Thursday = 6 August 2009
AddDays

the date that the library book must be returned by = AddDays(the date of loan,21)

the date that the library book must be returned by = the date 21 days after the date of loan

the date of loan: 2006-01-04

the date that the library book must be returned by = 25
SubtractDays

the closing date for the entry = AddDays(the date of the show,-10)

the closing date for the entry = the date 10 days before the date of the show

the date of the show: 2007-05-15 the closing date for the entry = 2007-05-05
AddWeeks

the date that the event finishes = AddWeeks(the date that the event begins,the number of weeks in the event)

the date that the event finishes = the date the number of weeks in the event weeks after the date that the event begins

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 start date of the 5 week promotion = AddWeeks(the end date of the promotion,-5)

the start date of the 5 week promotion = the date 5 weeks before the end date of the promotion

the end date of the promotion: 2008-12-24 the start date of the 5 week promotion = 2008-11-19
AddMonths

the date that the player can return from suspension = AddMonths(the date of the suspension,3)

the date that the player can return from suspension = the date 3 months after the date of the suspension

the date of the suspension: 2005-12-12

the date that the player can return from suspension = 2006-03-12

SubtractMonths

the start date of the player's 12 month contract = AddMonths(the end date of the player's contract,-12)

the start date of the player's 12 month contract = the date 12 months before the end date of the player's contract

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 trial = AddYears(the date of the crime,3)

the date of the trial = the date 3 years after the date of the crime

the date of the crime: 2002-01-01

the date of the trial = 2005-01-01
SubtractYears

the date that the prison sentence starts = AddYears(the date that the prison sentence ends,-20)

the date that the prison sentence starts = the date 20 years before the date that the prison sentence ends

the date that the prison sentence ends: 1980-03-16 the date that the prison sentence starts = 1960-03-16
WeekdayCount

the number of working days until my holiday = WeekdayCount(2007-12-03, 2007-12-13)

the number of business days in the specified period = the number of weekdays (inclusive) between 2007-10-15 and 2007-10-31

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 start of the first relevant year = YearStart(2009-09-09)

the start of the second relevant year = the first day of the year in which the date of the grand occasion falls

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 end of the relevant year = YearEnd(the relevant date)

the end of the relevant year = the last day of the year in which the relevant date falls

the relevant date: 2005-10-15 the end of the relevant year = 2005-12-31
DayDifference

the number of days in the assessment period = DayDifference(2006-10-01,2006-10-14)

date1: 2006-10-01

date2: 2006-10-14

the number of days in the assessment period = 13
DayDifferenceInclusive

the number of days in the assessment period = DayDifferenceInclusive(2006-10-01,2006-10-14)

date1: 2006-10-01

date2: 2006-10-14

the number of days in the assessment period = 14
DayDifferenceExclusive

the number of days in the assessment period = DayDifferenceExclusive(2006-10-01,2006-10-14)

date1: 2006-10-01

date2: 2006-10-14

the number of days in the assessment period = 12
WeekDifference

the number of weeks remaining = WeekDifference(the current date,the expiry date)

the current date: 2006-07-19

the expiry date: 2006-08-22

the number of weeks remaining = 4
MonthDifference

the number of months remaining = MonthDifference(the current date,the expiry date)

the current date: 2006-07-19

the expiry date: 2006-12-25

the number of months remaining = 5
YearDifference


the age of the tree in years = YearDifference(the date the tree was planted, the date the tree was assessed)

the age of the tree in years = the number of years between the date the tree was planted and the date the tree was assessed

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 age of the tree in years = YearDifferenceInclusive(the date the tree was planted, the date the tree was assessed)

the age of the tree in years = the number of years (inclusive) between the date the tree was planted and the date the tree was assessed

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

the calculation date =MakeDate(2006, 10, 19)

yyyy: 2006; mm: 10; dd: 19

the calculation date = 2006-10-19
ExtractDay

the day of expiry = ExtractDay(the use-by date on the packet)

the use-by date on the packet: 2008-06-12 the day of expiry = 12
ExtractMonth

the month of expiry = ExtractMonth(the use-by date on the packet)

the use-by date on the packet: 2007-04-16 the month of expiry = 04
ExtractYear

the year of expiry = ExtractYear(the use-by date on the packet)

the use-by date on the packet: 2009-02-21 the year of expiry = 2009
NextDate

the end of the Australian tax year = NextDate(the test date, 30, 6)

the test date: 2005-07-02

the end of the Australian tax year = 2006-06-30

UKNextTaxYearDates

the date of effect = the next UK tax year end date on or after the test date

the test date: 2003-09-21

the date of effect = 2004-04-05

UKPreviousTaxYearDates

the assessment date = the previous UK tax year start date on or before the test date

the test date: 2003-09-21 the assessment date = 2003-04-06
Latest (uses the Maximum function)

the last date to sign up = the latest of the first Monday in May and 2001-01-01

the most recent event date = Maximum(the July event date, the December event date)

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 first round of golf date = the earliest of the date on which Fred played golf and 2002-10-10

the earliest holiday start date = Minimum(2008-10-26, the start date of the annual leave)

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: