MySQL CURRENT_DATE() Function

The CURRENT_DATE() function in MySQL returns the current date. This function is equivalent to the CURDATE() function.


Definition and Usage

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

Syntax

CURRENT_DATE()

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 CURRENT_DATE();

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 CURRENT_DATE() + 1;

Output:

2024-12-29

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


Related Functions

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

Use Cases

  • Time-based Calculations: Useful for calculations involving the current date, such as determining due dates or expiration dates.
  • Date Comparison: Can be used in queries that compare dates, such as filtering records that are before or after today's date.

Was this article helpful?