MySQL 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.
MySQL Version: 8.0
Example: MySQL CURRENT_DATE
The following statement will return the current date in ‘YYYY-MM-DD’ format.
mysql> SELECT CURRENT_DATE; +--------------+ | CURRENT_DATE | +--------------+ | 2015-04-13 | +--------------+ 1 row in set (0.00 sec)
All Date and Time Functions:
Click here to see the MySQL Date and time functions.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join