Date and Time Functions
List of date and time functions
NOW
CURDATE
CURTIME
DATE
DATEDIFF
DATE_COMPUTE
DATETIME_COMPUTE
DAY
MONTH
YEAR
WEEKDAY
DATIME_COMPUTE
DATE_MAX
DATE_MIN
Within DecisionRules functions, date and time are represented by a date/time ISO string. Functions generating date like NOW or DATE therefore return string which can be then picked up by other date functions. On the other hand, most of the other date functions return numbers, like DATEDIFF, DAY, MONTH or YEAR.
Note that DATE function converts dates to Coordinated Universal Time (UTC) based on specified time zone and Daylight Saving Time (DST) settings. If no time zone is specified, CET (Central European Time) is used by default. For example, when entering a date like "04.16.2024", it adjusts to "2024-04-15T22:00" (using GMT+2 by default) to align with UTC. If another function uses DATE as a parameter, this adjusted date ("04.15.2024") is then utilized as required. Tip! You can append the letter "Z" to the end of the date provided within the DATE function. This indicates that the date should be treated as UTC and will not be converted to UTC. Examples:
Now (NOW)
Returns the current date and time.
Takes 1 optional argument.
When present, the optional argument specifies time zone.
Current date (CURDATE)
Returns the current date.
Takes 1 optional argument.
When present, the optional argument specifies time zone.
Current time (CURTIME)
Returns the current time.
Takes 1 optional argument.
When present, the optional argument specifies time zone.
Date (DATE)
Takes a string and returns a date (a date ISO string that can be picked up by other functions). The returned date and time are localized to UTC.
Takes 1 to 3 arguments.
The first argument is a string representing a date.
The second optional argument specifies custom format of the given date.
Third argument determinate what units are used for flooring. Possible values are: s= seconds, m= minutes and h= hours.
For details on how to write the second parameter specifying the date format, please see the Day.js Documentation.
Note that the function returns the result even for an invalid date as follows:
The values for the day can take 1-31 (depending on the month). If the range is exceeded, it will bubble up to the next month.
The values for the month can take 0-11 (Months are zero indexed, so January is month 0). If the range is exceeded, it will bubble up to the next year.
Date format (DATE_FORMAT)
Takes a date and converts it to required format.
Takes 2 arguments.
The first argument is the date to be converted (obtained from DATE, NOW or CURDATE).
The second argument is the required date format.
Note: This function depends on the output of the DATE function. For further details, refer to the info block at the beginning of this page
For a list of all possible date format values, please refer to the Day.js documentation under "List of available formats" (excluding Advanced and Localized format tokens)
Date difference (DATEDIFF)
Returns the number of specified time units between two dates. It may return negative or positive numbers, based on the order of the dates.
Takes 3 arguments.
The first and second argument is a date.
The third argument specifies the time unit, as listed below.
Date compute (DATE_COMPUTE)
Takes a date and adds or subtracts a specified time.
Takes 2 arguments.
The first argument is a date (obtained from DATE or NOW).
The second argument is the number of days to add.
Date Time compute (DATETIME_COMPUTE)
Takes a date and adds or subtracts a specified time unit.
Takes 3 arguments.
The first argument is a date (obtained from DATE or NOW).
The second argument is the number of units to add.
Third argument specifies units (s= seconds, h= hours, M= month, m= minutes, y= years)
Output date format is: YYYY-MM-DDTHH:mm:ss
Notice that all return values are in UTC format. For the precise calculation specify date format in DATE function.
Day (DAY)
Returns day from date
Takes 1 argument
The arguments must be a DATE object. Use the DATE function.
Month (MONTH)
Gets the month of the year for a given date.
Takes 1 argument.
The argument is a date (obtained from DATE or NOW).
Year (YEAR)
Gets the year of a given date.
Takes 1 argument.
The argument is a date (obtained from DATE or NOW).
Weekday (WEEKDAY)
Finds the day of the week of the given date.
Takes 1 argument.
The argument is a date (obtained from DATE or NOW).
The WEEKDAY function returns a number from 0 (meaning Sunday) to 6 (meaning Saturday).
Date Max (DATE_MAX)
Gets the maximum of inputted dates.
Takes 1 argument.
The argument is an array (or spread) date (obtained from DATE or NOW).
Date Min (DATE_MIN)
Gets the minimum of inputted dates.
Takes 1 argument.
The argument is an array (or spread) date (obtained from DATE or NOW).
Last updated