Time, date, and interval functions
Last modified: July 7, 2025
The driver supports the following data types and time, date, and interval functions.
Supported input types
timestamp_exp
– The timestamp expression can a column name, the result of another scalar function, or an ODBC time/date/timestamp escape with data typesSQL_CHAR
,SQL_VARCHAR
,SQL_TYPE_TIME
,SQL_TYPE_DATE
, orSQL_TYPE_TIMESTAMP
.date_exp
– The date expression can be a column name, the result of another scalar function, or an ODBC date/timestamp escape with the following data types:SQL_CHAR
,SQL_VARCHAR
,SQL_TYPE_DATE
, orSQL_TYPE_TIMESTAMP
.time_exp
– The time expression can be a column name, the result of another scalar function, or an ODBC time/timestamp escape with the following data types:SQL_CHAR
,SQL_VARCHAR
,SQL_TYPE_TIME
, orSQL_TYPE_TIMESTAMP
.
Time and date functions reference
Function | ODBC Version | Technical Description |
---|---|---|
CURRENT_DATE() |
3.0 | Returns the current date. |
CURRENT_TIME[( time-precision )] |
3.0 | Returns the current local time with optional precision for seconds. |
CURRENT_TIMESTAMP[( timestamp-precision )] |
3.0 | Returns the current local date and time as a timestamp with optional precision for seconds. |
CURDATE() |
1.0 | Returns the current date. |
CURTIME() |
1.0 | Returns the current local time. |
DAYOFMONTH( date_exp ) |
1.0 | Returns the day of the month (1-31 ) based on the given date. |
DAYOFWEEK( date_exp ) |
1.0 | Returns the day of the week (1-7 , where 1 represents Sunday). |
DAYOFYEAR( date_exp ) |
1.0 | Returns the day of the year (1-366 ) based on the given date. |
EXTRACT( extract-field FROM extract-source ) |
3.0 | Returns a specific component (extract-field ) from a datetime or interval expression (extract-source ). The extract-field argument can be one of the following: YEAR , MONTH , DAY , HOUR , MINUTE , SECOND . |
HOUR( time_exp ) |
1.0 | Returns the hour (0-23 ) based on the given time value. |
MINUTE( time_exp ) |
1.0 | Returns the minute component of time_exp as an integer in the range 0–59 . |
MONTH( date_exp ) |
1.0 | Returns the month as an integer value in the range of 1 to 12 based on the month field in the provided date_exp . |
NOW() |
1.0 | Returns the current date and time as a timestamp. |
QUARTER( date_exp ) |
1.0 | Returns the calendar quarter for a given date as an integer (1-4 ). |
SECOND( time_exp ) |
1.0 | Returns the second component of time_exp as an integer in the range of 0 to 59 . |
TIMESTAMPADD( interval, integer_exp, timestamp_exp ) |
2.0 | Adds integer_exp intervals of type interval to timestamp_exp and returns a new timestamp. Supported intervals include SQL_TSI_SECOND , SQL_TSI_MINUTE , SQL_TSI_HOUR , SQL_TSI_DAY , SQL_TSI_WEEK , SQL_TSI_MONTH , SQL_TSI_QUARTER , and SQL_TSI_YEAR . Behavior depends on the data type of timestamp_exp . |
WEEK( date_exp ) |
1.0 | Returns the week number (1-53 ) from the week field in date_exp . |
YEAR( date_exp ) |
1.0 | Returns the year from the year field in date_exp . |
Was this page helpful?