Time, Date and Interval Functions (ODBC Scalar Functions)
Function Descriptions
CURRENT_DATE()
Current date.
CURRENT_TIME([time_precision])
Current local time. The time_precision optional argument determines the seconds precision of the returned value.
CURRENT_TIMESTAMP([timestamp_precision])
Current local date and time as a timestamp value. The timestamp_precision optional argument determines the seconds precision of the returned value.
CUR_DATE()
Current date.
CURTIME()
Current local time.
DAYNAME(date_exp)
The name of the day of the passed date.
DAYOFMONTH(date_exp)
The number of the day in the month in date_exp, in the range of 1 – 31.
DAYOFWEEK(date_exp)
The number of the day of the week in date_exp, in the range 1-7 where 1 is Sunday.
DAYOFYEAR(date_exp)
The number of the day of the year in date_exp, in the range 1 – 366.
EXTRACT(extract_field FROM extract_source)
Extracts the extract_field portion of the extract_source. extract_source is a datetime or interval expression. extract_field can be one of the following keywords:
- YEAR
- MONTH
- DAY
- HOUR
- MINUTE
- SECOND
HOUR(time_exp)
The hour of the time_exp, in the range 0 – 23.
MINUTE(time_exp)
The minute in time_exp, in the range 0 – 59.
MONTH(date_exp)
The month in date_exp, in the range 1 – 12.
MONTHNAME(date_exp)
The name of the month in date_exp.
NOW()
Current date and time as a timestamp value.
QUARTER(date_exp)
The quarter in date_exp, in the range 1 – 4, where quarter 1 represents January 1 through March 31.
SECOND(time_exp)
The seconds in time_exp, in the range 0 – 59.
TIMESTAMPDIFF(interval, timestamp_exp1, timestamp_exp2)
The integer number of intervals that timestamp_exp2 is greater than timestamp_exp1. interval can be one of the following keywords:
- SQL_TSI_FRAC_SECOND
- SQL_TSI_SECOND
- SQL_TSI_MINUTE
- SQL_TSI_HOUR
- SQL_TSI_DAY
- SQL_TSI_WEEK
- SQL_TSI_MONTH
- SQL_TSI_QUARTER
- SQL_TSI_YEAR
WEEK(date_exp)
The week number of the year in date_exp, in the range 1 – 53.
YEAR(date_exp)
The year of date_exp.