CURRENT_DATE Examples – MySQL

In MySQL, the CURRENT_DATE function can be used to return the current date.

Actually, this function is a synonym for CURDATE() which returns the current date (so you can choose which one you prefer).

Both functions return the current date as a value in ‘YYYY-MM-DD’ or YYYYMMDD format, depending on whether the function is used in a string or numeric context.

Syntax

You can use either of the following forms:

CURRENT_DATE
CURRENT_DATE()

No arguments are required or accepted.

As mentioned, you can also use the following if preferred:

CURDATE()

Example – String Context

Here’s an example of using CURRENT_DATE in a string context.

SELECT CURRENT_DATE;

Result:

+--------------+
| CURRENT_DATE |
+--------------+
| 2018-06-23   |
+--------------+

And here’s an example of using both forms of the syntax, side by side, along with the CURDATE() function:

SELECT 
    CURRENT_DATE,
    CURRENT_DATE(),
    CURDATE();

Result:

+--------------+----------------+------------+
| CURRENT_DATE | CURRENT_DATE() | CURDATE()  |
+--------------+----------------+------------+
| 2018-06-23   | 2018-06-23     | 2018-06-23 |
+--------------+----------------+------------+

Example – Numeric Context

Here’s an example of using CURRENT_DATE in a numeric context.

SELECT CURRENT_DATE + 0;

Result:

+------------------+
| CURRENT_DATE + 0 |
+------------------+
|         20180623 |
+------------------+

In this example I added zero to the date. But I could also have added another number.

Here’s an example where I add 3 to the current date:

SELECT CURRENT_DATE + 5;

Result:

+------------------+
| CURRENT_DATE + 5 |
+------------------+
|         20180628 |
+------------------+

If you wish to keep the other format, you can always do something like this:

SELECT DATE_ADD(CURRENT_DATE, INTERVAL 5 day) AS Result;

Result:

+------------+
| Result     |
+------------+
| 2018-06-28 |
+------------+