Function Reference

DATE

Returns the date part of a datetime value, dropping the time.

MySQL 8.1
DATE(datetime)

Parameters

datetimeDATETIME
Datetime

Return value

A date (DATE); NULL if the value is not recognized as a date

Examples

Date without the time

MySQL 8.1
SELECT DATE('2022-12-05 10:37:22');
DATE('2022-12-05 10:37:22')
2022-12-05

Check-in date without the time

MySQL 8.1
SELECT id,
	start_date,
	DATE(start_date) AS start_day
FROM Reservations;
idstart_datestart_day
12018-11-13 12:00:002018-11-13
22018-10-09 12:00:002018-10-09
32018-12-29 12:00:002018-12-29
42019-02-01 12:00:002019-02-01
52019-02-02 12:00:002019-02-02
62020-03-21 09:00:002020-03-21
72020-03-21 10:00:002020-03-21
82019-06-14 10:00:002019-06-14
92019-05-11 10:00:002019-05-11
102019-11-04 10:00:002019-11-04

Details

DATE(NOW()) is the same as CURDATE(). To select rows for one day, it is better to compare with a range: start_date >= '2022-12-05' AND start_date < '2022-12-06'. The condition DATE(start_date) = '2022-12-05' gives the same result but cannot use an index on the column.

See also