MySQL CURDATE() Function

Summary: in this tutorial, you will learn how to use the MySQL CURDATE() function to get the current date.

Introduction to MySQL CURDATE() function

The CURDATE() function returns the current date as a value in the 'YYYY-MM-DD' format if it is used in a string context or YYYMMDD format if it is used in a numeric context.

The following example shows how the CURDATE() function is used in the string context.

mysql> SELECT CURDATE();
+------------+
| CURDATE()  |
+------------+
| 2017-07-13 |
+------------+
1 row in set (0.00 sec)
Code language: SQL (Structured Query Language) (sql)

The following example illustrates how the CURDATE() function is used in a numeric context:

mysql> SELECT CURDATE() + 0;
+---------------+
| CURDATE() + 0 |
+---------------+
|      20170713 |
+---------------+
1 row in set (0.04 sec)
Code language: SQL (Structured Query Language) (sql)

The CURRENT_DATE and CURRENT_DATE() are synonyms for CURDATE().

mysql> SELECT CURRENT_DATE(), 
              CURRENT_DATE, 
              CURDATE();
+----------------+--------------+------------+
| CURRENT_DATE() | CURRENT_DATE | CURDATE()  |
+----------------+--------------+------------+
| 2017-07-13     | 2017-07-13   | 2017-07-13 |
+----------------+--------------+------------+
1 row in set (0.00 sec)
Code language: SQL (Structured Query Language) (sql)

CURDATE vs. NOW

The CURDATE() function returns the current date with the date part only while the NOW() function returns both date and time parts of the current time.

The result of the CURDATE() function is equivalent to the following expression:

mysql> SELECT DATE(NOW());
+-------------+
| DATE(NOW()) |
+-------------+
| 2017-07-13  |
+-------------+
1 row in set (0.00 sec)
Code language: SQL (Structured Query Language) (sql)

In this tutorial, you have learned how to use the MySQL CURDATE() function to get the current date value.

Was this tutorial helpful?