Table 3


Date, time and interval scalar functions. "Type" refers to type_expression (for example, float is a reference to float_expression).

FUNCTION PURPOSE
CURDATE Returns the current date
CURTIME Returns the current time
CURRENT_DATE Returns the current date
CURRENT_TIME(time_precision) Returns the current time
CURRENT_TIMESTAMP(timestamp-precision) Returns the local date and local time as a timestamp
DAYNAME(date) Returns a string with the day of the week
DAYOFMONTH(date) Returns the day of the month, between 1 and 31
DAYOFWEEK(date) Returns the day of the week as an integer between 1 and 7
DAYOFYEAR(date) Returns the day of the year between 1 and 366
EXTRACT(extract-field FROM extract-source) Returns YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND field
of an extract-source (datetime or interval expression)
HOUR(time_exp) Returns the hour as an integer between 0 and 23
MINUTE(time_exp) Returns the minute as an integer between 0 and 59
MONTH(date) Returns the month as an integer between 1 and 12
MONTHNAME(date) Returns the month name as a string
NOW Returns the current date and time as a timestamp
QUARTER(date) Returns the quarter as an integer between 1 and 4
SECOND(time_exp) Returns the second as an integer between 0 and 59
TIMESTAMPADD
(interval,integer_exp,timestamp_exp)
Calculates a timestamp by adding integer_exp
intervals of type interval to timestamp_exp.
TIMESTAMPDIFF
(interval,timestamp_exp1,timestamp_exp2)
Returns the integer number of intervals by which
timestamp_exp2 is greater than timestamp_exp1.
WEEK(date) Returns the week of the year as an integer between 1 and 53
YEAR(date) Returns the year as an integer in a data source-dependent range