Name
CURDATE()
Synopsis
CURDATE()
This function returns the current system date in
yyyy-mm-dd format. It will return the date
in a yyyymmdd format (a numeric format) if
it’s used as part of a numeric calculation. You can use the function
in SELECT statements as shown here, in
INSERT and UPDATE statements to
set a value, or in a WHERE clause.
CURDATE() is synonymous with CURRENT_DATE(); see its definition next for more details.
Here is an example:
SELECT CURDATE() AS Today, CURDATE() + 1 AS Tomorrow; ow; +------------+----------+ | Today | Tomorrow | +------------+----------+ | 2007-01-15 | 20070116 | +------------+----------+
Because the second use of the function here involves a numeric
calculation, tomorrow’s date is displayed without dashes. If you only
want to convert a date to the numeric format, just add 0. To keep the
format the same, use this function together with a function such as
ADDDATE().
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access