MySQL CURRENT_DATE() Function
The CURRENT_DATE()
function in MySQL is a simple and efficient way to get the current date from the database server.
CURRENT_DATE(): Definition and Usage
This function is frequently used in database applications for tasks such as creating timestamps in database records, generating reports, or filtering data based on dates. The date is returned as a string ('YYYY-MM-DD') or as a numeric value (YYYYMMDD), depending on the context.
Equivalent Function
The CURDATE()
function is identical to CURRENT_DATE()
and provides the same result.
Syntax
Syntax
CURRENT_DATE()
Examples
Getting the Current Date
This query displays the current date.
Syntax
SELECT CURRENT_DATE();
Output
2024-10-27 (Example; the actual date will vary depending on when you run it)
Adding to the Current Date
Adding 1 to the date adds one day. The output format might vary slightly depending on your MySQL settings.
Syntax
SELECT CURRENT_DATE() + 1;
Output
2024-10-28 (Example; one day added to the current date)