Open In App

CURDATE() Function in MySQL

Improve
Improve
Like Article
Like
Save
Share
Report

The CURDATE() function in MYSQL is used to return the current date. The date is returned to the format of “YYYY-MM-DD” (string) or as YYYYMMDD (numeric). This function equals the CURRENT_DATE() function. In this article, we are going to discuss about CURDATE() function in detail.

Syntax

CURDATE();

Parameter

This method does not accept any parameter.

Returns

It returns the current date.

Query

Getting the current date in the format of YYYY-MM-DD (string).

SELECT CURDATE();

Output

output 1

output 1

Query

Getting the date 1 day later than the current date in the format of YYYYMMDD (numeric).

SELECT CURDATE() + 1;

Output

output 2

output 2

Query

Getting the date of 5 days before of current date in the format of YYYYMMDD (numeric).

SELECT CURDATE() + 5;

Output

output 3

output 3

Query

If you want to subtract the desired number of days from the current date using CURDATE() function.

SELECT CURDATE() -22;

Output

output4

output 4

Applications of CURDATE() Function

  • This function is used to get the current date or the specified number of days before or after the current date in the two different formats of YYYY-MM-DD (string) or as YYYYMMDD (numeric). 
  • you can also use CURDATE() function to find the differences between two dates.
  • you can also use the CURDATE() function to filter the records from the database.
  • you can also use the CURDATE() function to set as a default value for a date.


Last Updated : 28 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads