![]() |
VOOZH | about |
The DATE() function in MySQL is designed to extract the date portion (year, month, and day) from a given date, datetime or timestamp value. In this article, We will learn about DATE() in MySQL by understanding their examples.
DATE() function is used to extract the date part (year, month, and day) from a given date, datetime or timestamp value. Syntax:
DATE(expression)expression: This can be a date, datetime, or timestamp value from which you want to extract the date.
Below are some common examples or usages of the DATE() function :
SELECT DATE('2024-09-11 12:34:56');Output:
2024-09-11Select DATE("2020-06-23 10:34:29"); Output:
2020-06-23 SELECT DATE("The date is 2020-06-23"); Output:
NULL The DATE() function in MySQL is a crucial tool for extracting the date portion from datetime or timestamp values. It simplifies queries where only the date component is relevant, and it gracefully handles invalid formats by returning NULL.