Was this helpful?
Date and Time Functions
The DateTime category provides functions for dealing with date, time, and timestamp values. Unless specifically indicated otherwise, these functions accept values of any of the date and time types. If no time zone is supplied to functions taking an optional time zone argument, the default time zone as indicated by the JVM will be used.
Function Name
Description
Output Type
Parameters
DateTime.addTime
Adds a time period to a date/time value. For date and time of day values, time zone is ignored; the arithmetic is done in a zone-less fashion. Additionally, it is an error to add units smaller than a day to date values or units larger than an hour to time of day values.
same as input
Base date/time value
Duration of period
Granularity of period
Time zone (optional)
DateTime.currentDate
Gets the current date.
date
Time zone (optional)
DateTime.currentTime
Gets the current time of day.
time
Time zone (optional)
DateTime.currentTimestamp
Gets the current date and time of day.
timestamp
Time zone (optional)
DateTime.getValue
(Rushscript: dateTimeValue)
Extracts the wanted date or time field from the input value. It is an error to attempt to extract time fields from a date value or date fields from a time of day value.
int
Date/time value
Date/time field to extract
Time zone (optional)
DateTime.getTextValue
(Rushscript: dateTimeTextValue)
Extracts the wanted date or time field from the input value as human readable text. It is an error to attempt to extract time fields from a date value or date fields from a time of day value.
String
Date/time value
Date/time field to extract
Time zone (optional)
DateTime.subtractTime
Subtracts a time period from a date/time value. For date and time of day values, time zone is ignored; the arithmetic is done in a zone-less fashion. Additionally, it is an error to add units smaller than a day to date values or units larger than an hour to time of day values.
same as input
Base date/time value
Duration of period
Granularity of period
Time zone (optional)
DateTime.timeDiff
Computes the difference between two date/time values measured in a specified time unit and scale. Both values must be of the same type. When comparing time fields the highest precision is millisecond based whereas when comparing date fields the precision is day based. This means that when using date fields the difference will be based on the calendar intervals versus time fields which will use the more precise astronomical time intervals.
double
Start date/time value
End date/time value
Granularity of difference
Scale of resultant value (optional)
DateTime.toMilliseconds
Converts a date/time value into the number milliseconds since the epoch (January 1, 1970, 00:00:00 GMT). As time of day values have no date portion, this value will simply be the number of milliseconds since midnight. For date values, the result represents midnight of the associated day.
long
Date/time value
Time zone (optional)
DateTime.useDefaultTimeZone
Adjusts a timestamp value to use the default time zone offset.
timestamp
Timestamp value
DateTime.useTimeZone
Adjusts a timestamp value to use the time zone offset of the specified time zone.
timestamp
Timestamp value
Time zone
Part is a string constant, and must be one of the following:
"SECOND"
"SECOND_OF_MINUTE"
"MINUTE"
"MINUTE_OF_HOUR"
"HOUR", "HOUR_OF_DAY"
"DAY_OF_WEEK"
"DAY"
"DAY_OF_MONTH"
"DAY_OF_YEAR"
"WEEK"
"WEEK_OF_YEAR"
"MONTH"
"YEAR"
Granularity is a string constant, and must be one of the following:
"MILLISECOND"
"SECOND"
"MINUTE"
"HOUR"
"DAY"
"WEEK"
"MONTH"
"YEAR"
"CENTURY"
Time zone is a string constant. It can be given as an offset from GMT ("GMT-5", "GMT+8:30", etc.) or as a valid time zone name from the tz database ("America/Chicago", "Asia/Tokyo", "Europe/London", etc.). If no time zone is specified, the default time zone of the local machine will be used. If an invalid time zone is specified, the expression will be invalid.
Last modified date: 01/06/2023