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.
- 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.
- Example-2: Extracting date from a given DateTime.
Select DATE("2020-06-23 10:34:29");
- Example-3: Extracting date from a given date.
SELECT DATE("The date is 2020-06-23");
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- MySQL | Common MySQL Queries
- MySQL | BIN() Function
- PHP | MySQL WHERE Clause
- MongoDB vs MySQL
- MySQL | MD5 Function
- MySQL | IF( ) Function
- Difference between MySQL and IBM Db2
- IFNULL in MySQL
- How to get ID of the last updated row in MySQL?
- MySQL | USER( ) Function
- MySQL | VERSION( ) Function
- MySQL | NULLIF( ) Function
- MySQL | ISNULL( ) Function
- MySQL | CONVERT( ) Function
- MySQL | Ranking Functions
- MySQL | DEFAULT() Function
- Mathematical functions in MySQL
- MySQL | CONV( ) Function
- MySQL | DECODE( ) Function
- MySQL | COALESCE( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.