MySQL DATE() Function
Definition and Usage
The DATE() function returns the date part of a date or datetime expression.
Syntax
DATE(date)
date The parameter is a valid date expression.
Example
Assuming we have the following table:
OrderId | ProductName | OrderDate |
---|---|---|
1 | 'Computer' | 2008-12-29 16:25:46.635 |
We use the following SELECT statement:
SELECT ProductName, DATE(OrderDate) AS OrderDate FROM Orders WHERE OrderId=1
Result:
ProductName | OrderDate |
---|---|
'Computer' | 2008-12-29 |