MySQL CURRENT_DATE Function

MySQL CURRENT_DATE Function

MySQL CURRENT_DATE() function; Through this tutorial, we would love to share with you how to use CURRENT_DATE() MySQL with the help of examples.

And as well as, we will show you uses of MySQL CURRENT_DATE() with various MySQL functions 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() function with 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 MySQL CURRENT_DATE() function with various examples.

Recommended MySQL Tutorials

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

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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