MySQL Date/Time Functions
21 functions
NOWNOW()Returns the current date and time.
CURDATECURDATE()Returns the current date.
CURTIMECURTIME()Returns the current time.
DATEDATE(expr)Extracts the date part from a date/time expression.
TIMETIME(expr)Extracts the time part from a date/time expression.
YEARYEAR(date)Returns the year.
MONTHMONTH(date)Returns the month.
DAYDAY(date)Returns the day.
HOURHOUR(time)Returns the hour.
MINUTEMINUTE(time)Returns the minute.
SECONDSECOND(time)Returns the second.
DATE_FORMATDATE_FORMAT(date, format)Formats a date according to the specified format string.
STR_TO_DATESTR_TO_DATE(str, format)Parses a string into a date value.
DATE_ADDDATE_ADD(date, INTERVAL n unit)Adds an interval to a date.
DATE_SUBDATE_SUB(date, INTERVAL n unit)Subtracts an interval from a date.
DATEDIFFDATEDIFF(d1, d2)Returns the number of days between two dates.
TIMESTAMPDIFFTIMESTAMPDIFF(unit, d1, d2)Returns the difference between two dates in the specified unit.
LAST_DAYLAST_DAY(date)Returns the last day of the month.
DAYOFWEEKDAYOFWEEK(date)Returns the day of the week as a number (1=Sunday, 7=Saturday).
WEEKWEEK(date[, mode])Returns the week number of the year for the given date.
QUARTERQUARTER(date)Returns the quarter of the year.
