Date and Time Operators

Note: Date and time operators are not supported for aggregated items.
DateFromMDY
creates a date value from separate month, day, and year values. The first value specifies the month as a number from 1–12. The second value specifies the day as a number from 1–31. The third value specifies the year as a four-digit number.
For example, DateFromMDY(1, 15, 2013) returns 15JAN2013.
DateFromYQ
creates a date value from separate year and quarter values. The first value specifies the year as a four-digit number. The second value specifies the quarter as a number from 1–4.
For example, DateFromYQ(2013, 1) returns 01JAN2013.
Note: The date is generated using the first day of each quarter.
DatePart
converts a datetime value to a date value.
For example, DatePart('15JAN2013_17:15'dt) returns 15JAN2013.
DateTimeFromDateHMS
creates a datetime value from a date value and separate hour, minute, and second values. The first value specifies the date. The second value specifies the hour as a number from 0–23. The third value specifies the minute as a number from 0–59. The fourth value specifies the second as a number from 0–59.
For example, DateTimeFromDateHMS('15JAN2013'd, 17, 15, 23) returns January 15, 2013 05:15:23 PM
DateTimeFromTimeMDY
creates a datetime value from a time value and separate month, day, and year values. The first value specifies the time. The second value specifies the month as a number from 1–12. The third value specifies the day as a number from 1–31. The fourth value specifies the year as a four-digit number.
For example, DateTimeFromTimeMDY('_17:15:23'dt, 1, 15, 2013) returns January 15, 2013 05:15:23 PM.
DayOfMonth
returns the day of the month from a date value as a number from 1–31.
For example, DayOfMonth('15JAN2013'd) returns 15.
DayOfWeek
returns the day of the week from a date value as a number from 1–7 (1 is Sunday).
For example, DayOfWeek('15JAN2013'd) returns 3 (Tuesday).
DayOfYear
returns the day of the year from a date value as a number from 1–366.
For example, DayOfYear('15FEB2013'd) returns 46.
Hour
returns the hour from a time or datetime value as a number from 0–23.
For example, Hour('17:15:23't) returns 17.
Minute
returns the minute from a time or datetime value as a number from 0–59.
For example, Minute('17:15:23't) returns 15.
Month
returns the month from a date value as a number from 1–12.
For example, Month('15JAN2013'd) returns 1.
Now
creates a datetime value from the current date and time.
For example, Now() returns the current date and time.
Quarter
returns the quarter from a date value as a number from 1–4.
For example, Quarter('15AUG2013'd) returns 3.
Second
returns the second from a time or datetime value as a number from 0–59.
For example, Second('17:15:23't) returns 23.
TimeFromHMS
creates a time value from separate hour, minute, and second values. The first value specifies the hour as a number from 0–23. The second value specifies the minute as a number from 0–59. The third value specifies the second as a number from 0–59.
For example, TimeFromHMS(17, 15, 23) returns 05:15:23 PM.
TimePart
converts a datetime value to a time value.
For example, TimePart('15JAN2013_17:15:23'dt) returns 05:15:23 PM.
WeekNumber
returns the week of the year as a number from 0–53, where week 1 begins on the first Sunday of the year. Dates before the first Sunday of the year return 0.
For example, WeekNumber('04AUG2013'd) returns 31.
Year
returns the year from a date value as a four-digit number.
For example, Year('15JAN2013'd) returns 2013.
Last updated: January 8, 2019