MySQL Date and Time Functions

This page lists the date and time functions that can be used to manipulate temporal values in MySQL.

  1. ADDDATE

    The MySQL ADDDATE() function adds a date/time interval to a date or datetime value and returns the result.
  2. ADDTIME

    The MySQL ADDTIME() function adds a specified time value to another specified time and returns the result.
  3. CONVERT_TZ

    The MySQL CONVERT_TZ() function converts a time in one time zone to the time in another time zone.
  4. CURDATE

    The MySQL CURDATE() function returns the system’s current date in YYYY-MM-DD or YYYYMMDD format.
  5. CURRENT_DATE

    The MySQL CURRENT_DATE() function returns the system’s current date in YYYY-MM-DD or YYYYMMDD format.
  6. CURRENT_TIME

    The MySQL CURRENT_TIME() function returns the current time of the system in hh:mm:ss or hhmmss format.
  7. CURRENT_TIMESTAMP

    The MySQL CURRENT_TIMESTAMP() function returns the current date and time in the YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format.
  8. CURTIME

    The MySQL CURTIME() function returns the current time of the system in hh:mm:ss or hhmmss format.
  9. DATE

    The MySQL DATE() function extracts and returns the date part from a datetime value.
  10. DATE_ADD

    The MySQL DATE_ADD() function adds the specified interval to the specified date/time and returns the result.
  11. DATE_FORMAT

    The MySQL DATE_FORMAT() function formats a date or datetime value into a specific pattern.
  12. DATE_SUB

    The MySQL DATE_SUB() function subtracts a date or time interval from the specified date or datetime and returns the result.
  13. DATEDIFF

    The MySQL DATEDIFF() function returns the number of days between two date values.
  14. DAY

    The MySQL DAY() function returns a number representing the day of the month in a datetime expression.
  15. DAYNAME

    The MySQL DAYNAME() function returns the weekday name for a given date.
  16. DAYOFMONTH

    The MySQL DAYOFMONTH() function returns a number representing the day of the month in a datetime expression.
  17. DAYOFWEEK

    The MySQL DAYOFWEEK() function returns the weekday index of a given date.
  18. DAYOFYEAR

    The MySQL DAYOFYEAR() function returns a number from 1 to 366 representing the day of the year.
  19. EXTRACT

    The MySQL EXTRACT() function extracts and returns the specified part from the specified date/time.
  20. FROM_DAYS

    The MySQL FROM_DAYS() function converts the specified number of days to a date and returns it.
  21. FROM_UNIXTIME

    The MySQL FROM_UNIXTIME() function will convert unix_timestamp to a datetime and formats it as a string if a format string is specified.
  22. GET_FORMAT

    The MySQL GET_FORMAT() function returns a format string according to arguments.
  23. HOUR

    The MySQL HOUR() function extracts and returns the hour portion of a time.
  24. LAST_DAY

    The MySQL LAST_DAY() function returns the last day of the month for the specified date or datetime.
  25. LOCALTIME

    The MySQL LOCALTIME() function returns the current date and time in the YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format.
  26. LOCALTIMESTAMP

    The MySQL LOCALTIMESTAMP() function returns the current date and time in the YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format.
  27. MAKEDATE

    The MySQL MAKEDATE() function creates and returns a date based on the year and the number of days in the year.
  28. MAKETIME

    The MySQL MAKETIME() function creates a time based on the specified hour, minute, and second to and returns it.
  29. MICROSECOND

    The MySQL MICROSECOND() function extracts the microsecond part of a time or datetime and return it as a number.
  30. MINUTE

    The MySQL MINUTE() function extracts and returns the minute part of a time.
  31. MONTH

    The MySQL MONTH() function extracts the month part of a date and return it as a number.
  32. MONTHNAME

    The MySQL MONTHNAME() function returns the name of the month for a given date.
  33. NOW

    The MySQL NOW() function returns the current date and time in YYYY-MM-DD hh:mm:ss or YYYYMMDDhhmmss format.
  34. PERIOD_ADD

    The MySQL PERIOD_ADD() function adds the specified number of months to the specified year-month and returns the result as year-month.
  35. PERIOD_DIFF

    The MySQL PERIOD_DIFF() function returns the number of months between two periods specified by year and month.
  36. QUARTER

    The MySQL QUARTER() function returns the quarter of the year for a specified date.
  37. SEC_TO_TIME

    The MySQL SEC_TO_TIME() function converts the specified number of seconds to a time value in HH:MM:SS format.
  38. SECOND

    The MySQL SECOND() function extracts and returns the second part of a time.
  39. STR_TO_DATE

    The MySQL STR_TO_DATE() function converts the specified string to date/time according to the specified format.
  40. SUBDATE

    The MySQL SUBDATE() function subtracts a date or time interval from the specified date or datetime and returns the result.
  41. SUBTIME

    The MySQL SUBTIME() function subtracts a specified time interval from another specified time and returns the result.
  42. SYSDATE

    The MySQL SYSDATE() function returns the current time and date in the YYYY-MM-DD hh:mm:ssformat.
  43. TIME

    The MySQL TIME() function extracts the time part from a time or datetime and return it.
  44. TIME_FORMAT

    The MySQL TIME_FORMAT() function formats the time according to the specified format.
  45. TIME_TO_SEC

    The MySQL TIME_TO_SEC() function converts the specified time value to the number of seconds.
  46. TIMEDIFF

    The MySQL TIMEDIFF() function returns the difference between two time values.
  47. TIMESTAMP

    The MySQL TIMESTAMP() function sum all arguments and return the result as a datetime value.
  48. TIMESTAMPADD

    The MySQL TIMESTAMPADD() function adds the specified interval to a datetime value and returns the result.
  49. TIMESTAMPDIFF

    The MySQL TIMESTAMPDIFF() function returns the time interval between two datetimes.
  50. TO_DAYS

    The MySQL TO_DAYS() function converts the specified date to the number of days since year 0 and returns the result.
  51. TO_SECONDS

    The MySQL TO_SECONDS() function converts the specified date/datetime to seconds from 0 years and returns the result.
  52. UNIX_TIMESTAMP

    The MySQL UNIX_TIMESTAMP() function converts the specified date/datetime to a UNIX timestamp value.
  53. UTC_DATE

    The MySQL UTC_DATE() function returns the current UTC date.
  54. UTC_TIME

    The MySQL UTC_TIME() function returns the current UTC time.
  55. UTC_TIMESTAMP

    The MySQL UTC_TIMESTAMP() function returns the current UTC date and time.
  56. WEEK

    The MySQL WEEK() function returns the week number in the current year for the gaven date.
  57. WEEKDAY

    The MySQL WEEKDAY() function returns the weekday index for a given date.
  58. WEEKOFYEAR

    The MySQL WEEKOFYEAR() function returns the week number in the current year for the gaven date.
  59. YEAR

    The MySQL YEAR() function extracts the year part of a date and return it as a number.
  60. YEARWEEK

    The MySQL YEARWEEK() function returns a number representing the year and week of the given date.