MySQL Date Functions
This page shows you the most commonly used MySQL Date functions that allow you to manipulate date and time data effectively.
Function | Description |
---|---|
CURDATE | Returns the current date. |
DATEDIFF | Calculates the number of days between two DATE values. |
DAY | Gets the day of the month of a specified date. |
DATE_ADD | Adds a time value to date value. |
DATE_SUB | Subtracts a time value from a date value. |
DATE_FORMAT | Formats a date value based on a specified date format. |
DAYNAME | Gets the name of a weekday for a specified date. |
DAYOFWEEK | Returns the weekday index for a date. |
EXTRACT | Extracts a part of a date. |
LAST_DAY | Returns the last day of the month of a specified date |
NOW | Returns the current date and time at which the statement executed. |
MONTH | Returns an integer that represents a month of a specified date. |
STR_TO_DATE | Converts a string into a date and time value based on a specified format. |
SYSDATE | Returns the current date. |
TIMEDIFF | Calculates the difference between two TIME or DATETIME values. |
TIMESTAMPDIFF | Calculates the difference between two DATE or DATETIME values. |
WEEK | Returns a week number of a date. |
WEEKDAY | Returns a weekday index for a date. |
YEAR | Return the year for a specified date |