Select Date in SQL
? SELECT DATE() in SQL
The DATE() function extracts the date part (year-month-day) from a datetime or timestamp value, effectively removing the time portion.
Usage
SELECT DATE(datetime_column) FROM table_name;It returns only the date (YYYY-MM-DD).
Supported in MySQL and some other SQL dialects.
In SQL Server, use
CAST(datetime_column AS DATE)orCONVERT(DATE, datetime_column)instead.In PostgreSQL, use
::datecast orDATE()function.
? Examples:
MySQL:
SELECT DATE(order_date) AS order_only_dateFROM orders;SQL Server equivalent:
SELECT CAST(order_date AS DATE) AS order_only_dateFROM orders;PostgreSQL equivalent:
SELECT order_date::date AS order_only_dateFROM orders;Use Case
If a column stores date and time (like 2025-06-06 14:30:00), but you want just 2025-06-06, use DATE().
Would you like to see how to filter by date using DATE()?