Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

MySQL DATE() function


May 15, 2021 MySQL


Table of contents


MySQL DATE() function


MySQL DATE() function MySQL Date function

Definitions and usages

The DATE() function extracts the date portion of the date or date/time expression.

Grammar

DATE(date)

The date argument is a legitimate date expression.


Instance

Let's say we have the following "Orders" table:

OrderId ProductName OrderDate
1 Jarlsberg Cheese 2008-11-11 13:23:44.657

Here's the SELECT statement:

SELECT ProductName, DATE(OrderDate) AS OrderDate
FROM Orders
WHERE OrderId=1

The result is as follows:

ProductName OrderDate
Jarlsberg Cheese 2008-11-11


MySQL DATE() function MySQL Date function