The following table describes the supported date and time functions.
| Function | Description |
|---|---|
ADDDATE |
Adds a specified interval (such as days) to a date and returns the resulting date. |
ADDTIME |
Adds a specified time interval to a time or datetime value and returns the updated time or datetime. |
CONVERT_TZ |
Converts a datetime value from one time zone to another and returns the adjusted datetime value. |
CURDATE |
Returns the current date. |
CURRENT_DATE |
Synonym for CURDATE. |
CURRENT_TIME |
Returns the current time. |
CURRENT_TIMESTAMP |
Returns the current date and time. |
CURTIME |
Returns the current time. |
DATE |
Extracts and returns the date part of a datetime expression, removing the time portion. |
DATE_ADD |
Adds a specified interval (such as days or months) to a date and returns the resulting date. |
DATE_FORMAT |
Formats a date according to a specified format string using format specifiers. |
DATE_SUB |
Subtracts a specified interval from a date and returns the resulting date. |
DATEDIFF |
Returns the difference in days between two dates. |
DAY |
Returns the day of the month (1-31) from a date. |
DAYNAME |
Returns the name of the weekday for a given date. |
DAYOFMONTH |
Synonym for DAY. |
DAYOFWEEK |
Returns the weekday index (1 = Sunday, 2 = Monday, and so on) for a given date. |
DAYOFYEAR |
Returns the day of the year (1-366) for a given date. |
EXTRACT |
Extracts a specified part from a date or datetime value. |
FROM_DAYS |
Converts a number of days since year 0 to a date. |
FROM_UNIXTIME |
Converts a Unix timestamp to a datetime value. |
GET_FORMAT |
Returns the date/time display format. |
HOUR |
Extracts the hour from a time value. |
LAST_DAY |
Returns the last day of the month for a given date. |
LOCALTIME |
Synonym for CURRENT_TIMESTAMP. |
LOCALTIMESTAMP |
Synonym for CURRENT_TIMESTAMP. |
MAKEDATE |
Creates a date from a given year and day-of-year. |
MAKETIME |
Creates a time from given hour, minute, and second values. |
MICROSECOND |
Returns the microsecond part of a time or datetime value. |
MINUTE |
Extracts the minute from a time value. |
MONTH |
Extracts the month from a date. |
MONTHNAME |
Returns the name of the month for a given date. |
NOW |
Returns the current date and time. |
PERIOD_ADD |
Adds a specified number of months to a period. |
PERIOD_DIFF |
Returns the difference between two periods. |
QUARTER |
Returns the quarter of the year (1-4) for a given date. |
SEC_TO_TIME |
Converts a number of seconds into a time value. |
SECOND |
Extracts the second from a time value. |
STR_TO_DATE |
Converts a string into a date using a specified format. |
SUBDATE |
Subtracts a specified interval (such as days) from a date and returns the resulting date. |
SUBTIME |
Subtracts a time value from another time value and returns the resulting time. |
SYSDATE |
Returns the exact time at the moment the function is executed. |
TIME |
Extracts the time part from a datetime value. |
TIMEDIFF |
Returns the difference between two time or datetime values. |
TIMESTAMP |
Returns or converts a datetime value into a timestamp. |
TIMESTAMPADD |
Adds an interval to a timestamp and returns the resulting timestamp. |
TIMESTAMPDIFF |
Returns the difference between two timestamps in a specified unit. |
TO_DAYS |
Converts a date to a day count (number of days since the year 0). |
UTC_DATE |
Returns the current UTC date. |
UTC_TIME |
Returns the current UTC time. |
UTC_TIMESTAMP |
Returns the current UTC timestamp. |
WEEK |
Returns the week number for a given date, with the ability to specify the starting day of the week (Sunday or Monday) and a range of week numbers (from 0-53 or 1-53). |
WEEKDAY |
Returns the weekday index (0 = Monday, 1 = Tuesday, and so on) for a given date. |
WEEKOFYEAR |
Returns the calendar week of the year for a given date, in the range from 1 to 53. |
YEAR |
Extracts the year from a date. |
YEARWEEK |
Returns the year and week number for a given date. |
For more information, see the MySQL documentation: Date and Time Functions.