MySQueaL Resources

resources for mysql admins and developers who are squealing for help

More Resources

Main Doc Pages
Comments
MySQL columns: everywhere I look are tables and columns; life is filled with databases of information to be ordered and grouped. (Train Station, Venice, Italy)

CURDATE() Function

This MySQL function returns the current system date in yyyy-mm-dd format.

hits past month: 36 ;  last updated: may 4, 2009 - 2:34am ;  parent: MySQL Date & Time Functions

Syntax

CURDATE()

Explanation

This function returns the current system date in yyyy-mm-dd format. It will return the date in a yyyymmdd format, in a numeric format if it's used as part of a numeric calculation (see example). 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 for more details.

SELECT CURDATE() AS Today,
CURDATE() + 1 AS Tomorrow;

+------------+----------+
| 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( )

There are no examples for this page of our documentation. Return to MySQL Date & Time Functions page of our MySQL Documentation