MySQL CURDATE() Function
The CURDATE()
function in MySQL is a straightforward way to retrieve the current date from the database server. It's a handy function for various database operations that involve dates.
CURDATE(): Definition and Usage
This function is frequently used to record timestamps, generate reports, filter data based on dates, or perform date-related calculations within your MySQL applications. The date is returned as a string (YYYY-MM-DD) or a numeric value (YYYYMMDD), depending on how you use it in your query.
Equivalent Function
The CURRENT_DATE()
function is identical to CURDATE()
. They both return the current date.
Syntax
Syntax
CURDATE()
Examples
Getting the Current Date
This simple query returns today's date.
Syntax
SELECT CURDATE();
Output
2024-10-30 (Example output; the date will change depending on when you run the query)
Adding to the Current Date
Adding 1 to the current date adds one day. Note that the result's format might vary slightly depending on your MySQL server's settings.
Syntax
SELECT CURDATE() + 1;
Output
2024-10-31 (Example output; one day added to the current date)