MySQL CURDATE() Function

The CURDATE() function in MySQL returns the current date. It is useful for retrieving today's date in your queries.


Definition and Usage

  • The CURDATE() function returns the current date as a string in the format YYYY-MM-DD or as a numeric value in the YYYYMMDD format.

Syntax

CURDATE()

Technical Details

  • Works in: From MySQL 4.0
  • Return Value: Returns the current date in the format YYYY-MM-DD.

Examples

Example 1: Return the current date

SELECT CURDATE();

Output:

2024-12-28

This will return the current date in the YYYY-MM-DD format.

Example 2: Return the current date + 1 (next day's date)

SELECT CURDATE() + 1;

Output:

2024-12-29

This query adds 1 day to the current date and returns the next day's date.


Related Functions

  • CURRENT_DATE(): Equivalent to CURDATE().
  • NOW(): Returns the current date and time.
  • CURRENT_TIME(): Returns the current time.
  • CURTIME(): Returns the current time.

Use Cases

  • Time-based Calculations: To find the current date and perform calculations based on it (e.g., due dates, expiration dates).
  • Date Comparison: Useful in queries where you need to compare dates, like checking if a record's date is after or before today's date.

Was this article helpful?