Datetime built-in functions

Datetime built-in functions allow you to manipulate datetime values. There are many different datetime functions. The commonly used datetime built-in functions are listed next. Note that each of them can be used with a date value, a column with date values, or an expression that contains date values.

To get the current date or time, use the following:

  • CURRENT_DATE: This returns the current date.
  • CURRENT_DATE(): This returns the date in YYYY-MM-DD format—that is, 2020-01-11.
  • CURRENT_TIME—This returns the current time.
  • CURRENT_TIME(): This returns the time in HH:MM:SS format—that is, 21:09:27.
  • CURRENT_TIMESTAMP: This returns the current date and time.
  • CURRENT_TIMESTAMP(): This returns the datetime in YYYY-MM-DD ...

Get Learn SQL Database Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.