Date and time function rule examples

Date and time functions are used with date and time variables to express the current date and time (at the start of the session), to set the date and time, to calculate the difference in units between two dates, to extract a unit from a date and time, to extract a time of day, and to get an earliest/latest date and time.

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

CurrentDateTime

the date and time of the investigation = CurrentDateTime()

the current date time: 2009-09-15 03:24:12 the date and time of the investigation = 2009-09-15 03:24:12
DateTime

the latest submission date and time= DateTime(the submission date and time specified on the application form)

the submission date and time specified on the application form: 2012-12-31 18:00:00 the latest submission date and time= 2012-12-31 18:00:00
ConcatenateDateTime

the latest submission date and time = ConcatenateDateTime(the submission date, the submission closing time)

the submission date: 2010-01-15

the submission closing time: 17:00:00

the latest submission time = 2010-01-15 17:00:00
SecondDifference

the number of seconds between first place and second place = SecondDifference(the first place time, the second place time)

the first place time: 2008-06-30 09:31:05

the second place time: 2008-06-30 09:31:10

the number of seconds between first place and second place = 5
MinuteDifference

the number of minutes late the plumber is = MinuteDifference(the time the plumber was meant to arrive, the time that the plumber actually arrived)

the time the plumber was meant to arrive: 2009-10-18 08:30:00

the time that the plumber actually arrived: 2009-10-18 09:00:40

the number of minutes late the plumber is = 30
HourDifference

the number of hours the plane was delayed by = HourDifference(the scheduled arrival time of the flight, the arrival time of the delayed flight)

the scheduled arrival time of the flight: 2006-10-13 09:50:00

the arrival time of the delayed flight: 2006-10-13 11:00:00

the number of hours the plane was delayed by = 1
DayDifference

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

date time1: 2006-10-01 12:00:00

date time2: 2006-10-14 12:00:00

the number of days in the assessment period = 13
DayDifferenceInclusive

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

date time1: 2006-10-01 12:00:00

date time2: 2006-10-14 12:00:00

the number of days in the assessment period = 14
DayDifferenceExclusive

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

date time1: 2006-10-01 12:00:00

date time2: 2006-10-14 12:00:00

the number of days in the assessment period = 12
WeekDifference

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

the current date time: 2006-07-19 16:30:00

the expiry date time: 2006-08-22 17:00:00

the number of weeks remaining = 4
MonthDifference

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

the current date time: 2006-07-19 16:30:00

the expiry date time: 2006-12-25 17:00:00

the number of months remaining = 5
YearDifference

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

the date time that the tree was planted: 2000-03-12 10:40:00

the date time that the tree was assessed: 2003-12-12 12:05:00

the age of the tree in years = 3
ExtractSecond

the second component of the submission time = ExtractSecond(the submission time)

the submission time: 2004-02-21 14:42:32 the second component of the submission time = 32
ExtractMinute

the minute component of the submission time = ExtractMinute(the submission time)

the submission time: 2004-02-21 14:42:32 the minute component of the submission time = 42
ExtractHour

the hour component of the submission time = ExtractHour(the submission time)

the submission time: 2004-02-21 14:42:32 the hour component of the submission time = 14
ExtractDay

the password expiry day = ExtractDay(the password expiry date time)

the password expiry date time: 2009-09-11 00:00:00 the password expiry day = 11
ExtractMonth

the password expiry month = ExtractMonth(the password expiry date time)

the password expiry date time: 2009-09-11 00:00:00 the password expiry month = 09
ExtractYear

the password expiry year = ExtractYear(the password expiry date time)

the password expiry date time: 2009-09-11 00:00:00 the password expiry year = 2009
ExtractTimeOfDay

the time of the assessment = ExtractTimeOfDay(the current date time)

the current date time: 2009-09-04 10:46:12 the time of the assessment = 10:46:12
Latest (uses the Maximum function)

the last time to enrol = Maximum(2011-03-06 17:30:00, 2012-03-06 17:30:00)

date time1: 2011-03-06 17:30:00

date time2: 2012-03-06 17:30:00

the last time to enrol = 2012-03-06 17:30:00
Earliest (uses the Minimum function)

the earliest time to book in = Minimum(2009-12-31 23:59:59, the book in time allocated to the group)

date time 1: 2009-12-31 23:59:59

the book in time allocated to the group: 2010-01-02 00:00:00

the earliest time to book in = 2009-12-31 23:59:59

 

See also: