Open In App
Related Articles

DATE() in MySQL

Improve Article
Improve
Save Article
Save
Like Article
Like

The DATE() function is used to extract the date part from a DateTime expression. This function is an inbuilt function in MySQL. The DATE() function in MySQL can be used to know the date for a given date or a DateTime. The DATE() function takes a date value as an argument and returns the date. The date argument represents the valid date or DateTime.

Syntax :

select date('Expression'); 
  • Parameter : It accepts only one parameter.
  • Expression : It represents the date/datetime value.
  • Return Value : It returns the date and returns NULL if the expression is not a date.

Below are some common examples or usages of the DATE() function :

  • Example-1: Extracting date from a given date.
    Select DATE('2020-06-23'); 

    Output :

    2020-06-23 
  • Example-2: Extracting date from a given DateTime.
    Select DATE("2020-06-23 10:34:29"); 

    Output :

    2020-06-23 
  • Example-3: Extracting date from a given date.
    SELECT DATE("The date is 2020-06-23"); 

    Output :

    NULL 
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Last Updated : 06 Jul, 2020
Like Article
Save Article
Previous
Next
Similar Reads