Date Functions in Expressions

Date functions perform an operation on a date and time input value and return a string, numeric, or date and time value.

The following information describes the functions available for building expressions.

Tip:
  • Any information within square brackets [ ] is optional.
  • For more information on formatting strings, see Conversion Functions.
  • If you want the current date/time associated with the UTC time zone, use the format CurrentDateTime("UTC").

DATE

Description
Returns a date value representing a specified year, month, day, hour, minute, or second. The default value for date/time is always associated with the current time zone, unless a time zone is specified using a different function in the expression. Any actions performed in the same expression using this resultant value uses the current or specified time zone for evaluation.
Note: If this function is used as the return value of an expression, the DateTime will be in universal time (UTC).
Format
DATE(int_year, int_month, int_day, [, int_hour, int_minute, int_second], [, timezone]])
ParametersRequired?Data TypeDescription
int_yearYesNumericInteger for the year field of the date.
int_monthYesNumericInteger for the month field of the date.
int_dayYesNumericInteger for the day field of the date.
int_hourNoNumericInteger for the hour field of the date.
int_minuteNoNumericInteger for the minute field of the date.
int_secondNoNumericInteger for the second field of the date.
timezoneNoStringAbbreviation of the time zone of the date.
Example
DATE(2008,10,31,11,59,59)
DATE(2008,10,31)
DATE(2008,10,31,11,59,59,"MST")

CurrentDateTime

Description
Returns the current date and time. The default value for date/time is always associated with the current time zone, unless a time zone is specified using a different function in the expression. Any actions performed in the same expression using this resultant value uses the current or specified time zone for evaluation.
To work with UTC values, you can use the UTC time zone. You can do this by specifying it in a DateTime function, or by converting the DateTime value to the UTC time zone. For example, the DateTime function can be expressed as CurrentDateTime("UTC") or as ConvertTimeZone({dateTimeVariable}, "UTC".
Note: If this function is used as the return value of an expression, the DateTime will be in universal time (UTC).
Format
CurrentDateTime([timezone])
ParametersRequired?Data TypeDescription
timezoneNoStringTime zone to get the current date and time from.

DateTimeCompare

Description
Compares two Date-Time values and returns an indication of their relative values; that is, an integer that indicates whether the first instance is earlier than, the same as, or later than the second instance.
Format
DateTimeCompare(dateTime1, dateTime2)
ParametersRequired?Data TypeDescription
dateTime1YesDateTimeFirst date and time value to compare.
dateTime2YesDateTimeSecond date and time value to compare.
Example
DateTimeCompare(DATE(1899,10,31,11,59,59) , DATE(1999,10,31,11,59,59) ) < 0
DateTimeCompare(DATE(1999,10,31,11,59,59) , DATE(1999,10,31,11,59,59) ) = 0
DateTimeCompare(DATE(1999,10,31,11,59,59) , DATE(1899,10,31,11,59,59) ) > 0

Today

Description
Returns the current date as a date and time value. The default value for date/time is always associated with the current time zone, unless a time zone is specified using a different function in the expression. Any actions performed in the same expression using this resultant value uses the current or specified time zone for evaluation. The time part of the day is zero (midnight).
Note: If this function is used as the return value of an expression, the DateTime will be in universal time (UTC).
Format
TODAY([timezone])
ParametersRequired?Data TypeDescription
timezoneNoStringTime zone to get the current date from.

Year

Description
Returns the year corresponding to the specified date.
Tip: The DateTime input parameter takes into account the associated time zone of the input during evaluation.
Format
YEAR(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the year from.

Month

Description
Returns a number between 1 and 12 (inclusive) representing the month of the year, corresponding to the specified date.
Tip: The DateTime input parameter takes into account the associated time zone of the input during evaluation.
Format
MONTH(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the month from.

Day

Description
Returns a number between 1 and 31 (inclusive) representing the day of the month, corresponding to the specified date.
Format
DAY(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the day from.

Hour

Description
Returns a number between 0 and 23 (inclusive) representing the hour of the day.
Example
Hour(CurrentDateTime("MST")) will give a result 2 off of Hour(CurrentDateTime("EST")).
Format
HOUR(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the hour from.

Minute

Description
Returns a number between 0 and 59 (inclusive) representing the minute of the hour.
Tip: The DateTime input parameter takes into account the associated time zone of the input during evaluation.
Format
MINUTES(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the minute from.

Second

Description
Returns a number between 0 and 59 (inclusive) representing the second of the minute.
Format
SECOND(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate to get the seconds from.

DatePart

Description
Returns an integer value containing the specified component of a given DateTime value, such as the month or year.
Format
DatePart(component, date [, firstdayofweek [, firstweekofyear]])
ParametersRequired?Data TypeDescription
componentYesNumeric or StringValues representing which time component to extract:
  • 0 or “yyyy” = year
  • 1 or “q” = quarter
  • 2 or “m” = month
  • 3 or “y” = day of year (1 to 366)
  • 4 or “d” = day of month (1 to 31)
  • 5 or “ww” = week of year (1 to 53)
  • 6 or “w” = day of Week (1 to 7)
  • 7 or “h” = hour
  • 8 or “n” = minute
  • 9 or “s” = second
dateYesDateTimeValue to extract from.
firstdayofweekNoNumericValues indicating which day to consider as the first day of the week:
  • 0 = System setting
  • 1 = Sunday (default)
  • 2 = Monday
  • 3 = Tuesday
  • 4 = Wednesday
  • 5 = Thursday
  • 6 = Friday
  • 7 = Saturday
firstweekofyearNoNumericValues indicating whether to consider the first week of a year to be:
  • 0 = System setting
  • 1 = week in which Jan 1 occurs
  • 2 = week that has at least 4 days in the new year
  • 3 = first full week in the new year

DateOnly

Description
Gets the date component of a DateTime value, with the time zeroed out.
Tip: The DateTime input parameter takes into account the associated time zone of the input during evaluation.
Format
DateOnly(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate and time from which the date is isolated.

ConvertTimeZone

Description
Changes the time zone associated with a DateTime value. This function does not change the specific time being referenced; that is, the universal (UTC) time remains the same. A DateTime value that is associated with the time zone is returned.

To work with UTC values, you can use the UTC time zone. You can do this by specifying it in a DateTime function, or by converting the DateTime value to the UTC time zone. For example, the DateTime function can be expressed as CurrentDateTime("UTC") or as ConvertTimeZone({dateTimeVariable}, "UTC".

Example
If 3:00 p.m. MST is converted to EST, then the result displayed is 5:00 p.m. EST. The time does not change, but it is associated with a different time zone.
Format
ConvertTimeZone(date, timeZoneID)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate and time to associate with a timezone.
timeZoneIDYesStringRepresents the time zone.

SpecifyTimeZone

Description
Specifies the time zone of a time value. A DateTime value that is associated with the local time is returned.
Example
If 3:00 p.m. MST is specified as EST, then the result is 3:00 p.m. EST. The time of the output value is the same at the input value.
Format
SpecifyTimeZone(date, timeZoneID)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate and time to associate with a time zone.
timeZoneIDYesStringRepresents the time zone.

GetTimeZone

Description
Gets the time zone the date is associated with. A string value that represents the associated time zone is returned.
Format
GetTimeZone(date)
ParametersRequired?Data TypeDescription
dateYesDateTimeDate and time to get the associated time zone from.