THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL DATE() Function

❮ MySQL Functions

Example

Extract the date value:

SELECT DATE("2017-06-15");
Try it Yourself »

Definition and Usage

The DATE() function extracts the date value from a date or datetime expression.

Syntax

DATE(expression)

Parameter Values

Parameter Description
expression Required.  The date/datetime value from which the date should be extracted. Returns NULL if expression is not a date or a datetime value

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

More Examples

Example

Extract the date value:

SELECT DATE("2017-06-15 09:34:21");
Try it Yourself »

Example

Extract the date value (will return NULL):

SELECT DATE("The date is 2017-06-15");
Try it Yourself »

Example

Extract the date value:

SELECT DATE(OrderDate) FROM Orders;
Try it Yourself »

❮ MySQL Functions