MySQL CURRENT_DATE() function
CURRENT_DATE() function
In MySQL, the CURRENT_DATE returns the current date in ‘YYYY-MM-DD’ format or YYYYMMDD format depending on whether numeric or string is used in the function. CURDATE() and CURRENT_DATE() are the synonym of CURRENT_DATE.
Note: All of the example codes of this page will produce outputs depending upon the current date.
This function is useful in -
- Keeping track of events, transactions, and changes in a database is essential.
- Time intervals and date ranges are useful when filtering and querying data.
- CURRENT_DATE() can help determine an individual's current age when calculating their age, especially when it is combined with the person's birthdate.
- By comparing outdated or obsolete records to the current date, CURRENT_DATE() can identify and remove them.
- In logging systems, CURRENT_DATE() is used to timestamp log entries, making it easier to track events and troubleshoot problems.
Syntax:
CURRENT_DATE
Syntax Diagram:
MySQL Version: 8.0
Pictorial Presentation:
Example: MySQL CURRENT_DATE
The following statement will return the current date in ‘YYYY-MM-DD’ format.
Code:
SELECT CURRENT_DATE;
Output:
mysql> SELECT CURRENT_DATE; +--------------+ | CURRENT_DATE | +--------------+ | 2015-04-13 | +--------------+ 1 row in set (0.00 sec)
Video Presentation:
All Date and Time Functions:
Click here to see the MySQL Date and time functions.
Previous: CURDATE()
Next: CURRENT_TIME()
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics