MySQL CURRENT_DATE Function Examples – MySQL

In MySQL CURRENT_DATE() function tutorial, we would love to share with you how to use CURRENT_DATE() MySQL in query. We will provide various examples of CURRENT_DATE() function in this tutorial. We will show you uses of mysql CURRENT_DATE() with various MySQL function such as YEAR(), MONTH(), WEEK(), DAYNAME(), MONTHNAME() etc.

Basically CURRENT_DATE() function returns the current date in various formats, such as ‘YYYY-MM-DD’ or ‘YYYYMMDD’ format.

In our previous tutorial, we have shared a list of MySQL Date functions that are available to work with Date and time.

MySQL CURRENT_DATE() & Examples

In MySQL Tutorial, The CURRENT_DATE() function returns the current date in various formats, such as ‘YYYY-MM-DD’ or ‘YYYYMMDD’ format, depending on whether the numerical or string is used in the function.

As the name suggest CURDATE() function, basically CURRENT_DATE() function synonym for CURDATE(). Both(CURRENT_DATE(), CURDATE()) functions return the current date as a value in YYYY-MM-DD or YYYYMMDD format.

Syntax:

CURRENT_DATE ()

Examples MySQL CURRENT_DATE() function

let’s take various examples of MySQL CURRENT_DATE() function.

Example-1

let’s take example-1, the below statement will return the current date in ‘YYYY-MM-DD’ format.

SELECT CURRENT_DATE();

Output-1

 +---------------------+
 | CURRENT_DATE()      |
 +---------------------+
 | 2019-07-05          | 
 +---------------------+

Example-2

let’s take example-2, the below statement will return the current date in ‘YYYYMMDD’ format.

SELECT CURRENT_DATE()+1;

Output-2

 
 +---------------------+
 | CURRENT_DATE()+1    |
 +---------------------+
 |    20190706         | 
 +---------------------+

Example-3

let’s take example-3, the below statement will return the Day number from current date.

SELECT DAY(CURRENT_DATE());

Output-3

 
 +---------------------+
 | CURRENT_DATE()      |
 +---------------------+
 | 5                   | 
 +---------------------+

Example-4

let’s take example-4, the below statement will return the year number from current date.

SELECT YEAR(CURRENT_DATE());

Output-4

 
 +----------------------+
 |YEAR(CURRENT_DATE())  |
 +----------------------+
 | 2019                 | 
 +----------------------+

Example-5

let’s take example-5, the below statement will return the month number from current date.

SELECT MONTH(CURRENT_DATE());

Output-5

 
 +-------------------------+
 |MONTH(CURRENT_DATE())    |
 +-------------------------+
 | 7                       | 
 +-------------------------+

Example-6

let’s take example-6, the below statement will return the week number from current date.

SELECT WEEK(CURRENT_DATE());

Output-6

 
 +-------------------------+
 |WEEK(CURRENT_DATE());    |
 +-------------------------+
 | 26                      | 
 +-------------------------+

Example-7

let’s take example-7, the below statement will return the day name of week from current date.

SELECT DAYNAME(CURRENT_DATE());

Output-7

 
 +-------------------------+
 |DAYNAME(CURRENT_DATE()); |
 +-------------------------+
 | Friday                  | 
 +-------------------------+

Example-8

let’s take example-8, the below statement will return the month name from current date.

SELECT MONTHNAME(CURRENT_DATE());

Output-8

 +-------------------------+
 |DAYNAME(CURRENT_DATE()); |
 +-------------------------+
 | July                    | 
 +-------------------------+

Conclusion

In this mysql tutorial we have discussed about mysql CURRENT_DATE() function with various examples.

If you have any questions or thoughts to share, use the comment form below to reach us.

Spread the love

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *