Date and time function rule examples

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 and to extract a time of day.

Be sure to use the exact syntax for these functions including spacing and parentheses as specified below.

Rule examples

Function Example rule Inputs

Outputs

Further information
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 Get the current date and time
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 Get a date and time from a text string
ConcatenateDateTime

the latest submission 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 Get a date and time by joining together a separate date and time
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 Count the number of seconds between two times
SecondDifferenceInclusive

the number of seconds between first place and second place = SecondDifferenceInclusive(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 = 6
SecondDifferenceExclusive

the number of seconds between first place and second place = SecondDifferenceExclusive(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 = 4
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 Count the number of whole minutes between two times
MinuteDifferenceInclusive

the number of minutes late the plumber is = MinuteDifferenceInclusive(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 = 31
MinuteDifferenceExclusive

the number of minutes late the plumber is = MinuteDifferenceExclusive(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 = 29
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 Count the number of whole hours between two times
HourDifferenceInclusive

the number of hours the plane was delayed by = HourDifferenceInclusive(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 = 2
HourDifferenceExclusive

the number of hours the plane was delayed by = HourDifferenceExclusive(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 = 0
ExtractDate

the password expiry date = ExtractDate(the password expiry date time)

the password expiry date time: 2009-09-11 00:00:00 the password expiry date = 2009-09-11 Get the date from a date and time
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 Get the time of day from a date and time
AddHours

the date time that the offer expires = AddHours(the date time that the offer starts, 48)

the date time that the offer starts: 2010-10-08 12:00:00 the date time that the offer expires = 2010-10-10 12:00:00 Get a date and time by adding or subtracting a specified number of hours to another date and time
AddMinutes

the date time that the train is due = the time 25 minutes after the date time that the train departed

the date time that the train departed: 2005-01-16 22:50:00 the date time that the train is due = 2005-01-16 23:15:00 Get a date and time by adding or subtracting a specified number of minutes to another date and time
AddSeconds

the date time at the start of the recording = the time 40 seconds before the date time at the end of the recording

the date time at the end of the recording: 2008-01-01 14:27:52 the date time at the start of the recording = 2008-01-01 14:27:12 Get a date and time by adding or subtracting a specified number of seconds to another date and time

 

TIP: The localized syntax for these functions may be viewed:

 

See also: