DateTime module
The DateTime module
The DateTime module contains additional functions for creating and consuming date and time values.
Please note that the DateTime module is currently only available in Script Steps.
Note, also, that all the functions in the DateTime module work on textual values as well as date values explicitly created using the Date function; for instance, calling DateTime.GetYear("2018-01-01")
returns the same result as calling DateTime.GetYear(Date("2018-01-01"))
.
IsValidDate(candidate)
Returns a Boolean value indicating whether the candidate value is a valid date (or date and time)
CreateDate(year, month, dayOfMonth)
Creates a date value with the given year, month and day of the month. The timestamp of the created value will be 00:00:00. Please note that the month and day of the month are 1-based.
CreateDateAndTime(year, month, dayOfMonth, hour, minute, second)
Creates a date value with the given year, month, day of the month, hour, minute and second. Please note that the month and day of the month are 1-based and that the hour
argument is in 24h time.
GetYear(dateValue)
Gets the year of a date.
GetMonth(dateValue)
Gets the month of a date.
GetDayOfMonth(dateValue)
Gets the day of the month of a date.
GetHour(dateValue)
Gets the hour component of a date.
GetMinute(dateValue)
Gets the minute of a valid date.
GetSecond(dateValue)
Gets the second of a date.
DifferenceInDays(fromDate, toDate)
Returns a numeric value representing the (possibly fractional) number of days between the fromDate
and toDate
arguments. If toDate is earlier than fromDate, the resulting value will be negative.
DifferenceInSeconds(fromDate, toDate)
Returns a numeric value representing the number of seconds between the fromDate
and toDate
arguments. If toDate is earlier than fromDate, the resulting value will be negative.
SetTime(dateValue, hours, minutes, seconds)
Returns a new date value with the same year, month and day as dateValue
, but with a new time as specified in the hours,
minutes
and seconds
arguments.
AddYears(dateValue, years)
Returns a new date value with the 'year' component offset by the number of years specified in the years
argument. (To subtract, specify a negative number.)
AddMonths(dateValue, months)
Returns a new date value with the 'month' component offset by the number of months specified in the months
argument. (To subtract, specify a negative number.)
AddDays(dateValue, days)
Returns a new date value with the 'day' component offset by the number of days specified in the days
argument. (To subtract, specify a negative number.)
Note: for values which are known to be dates (i.e. created using the Date
or Now
functions), it is possible to use the addition (+) and subtraction (-) operators as shorthand for the AddDays function.
AddHours(dateValue, hours)
Returns a new date value with the 'hour' component offset by the number of hours specified in the hours
argument. (To subtract, specify a negative number.)
AddMinutes(dateValue, minutes)
Returns a new date value with the 'minute' component offset by the number of minutes specified in the minutes
argument. (To subtract, specify a negative number.)
AddSeconds(dateValue, seconds)
Returns a new date value with the 'second' component offset by the number of seconds specified in the seconds
argument. (To subtract, specify a negative number.)
CreateHHMMText(dateValue)
Converts a valid date value into a textual value containing the hour and minute of the day in the HH:MM format. This is the format supported by the Time input element.
GetHourFromHHMMText(text)
Gets the hour component from a text in the HH:MM format (as created by the Time input element).
GetMinuteFromHHMMText(text)
Gets the minute component from a text in the HH:MM format (as created by the Time input element).
Last updated