Function Reference

DATE

Converts a value to the date type and drops the time.

PostgreSQL 17.5
DATE(value)

Parameters

valuetimestamp | text
Timestamp or a string with a date

Return value

A date (date) without time; a string with a non-existent date causes an error

Examples

Date without time

PostgreSQL 17.5
SELECT DATE('2022-12-05 10:37:22');
date
2022-12-05

The same with the :: operator

PostgreSQL 17.5
SELECT DATE('2022-12-05 10:37:22') AS function_style,
	'2022-12-05 10:37:22'::date AS cast_style;
function_stylecast_style
2022-12-052022-12-05

Details

DATE(value) is a type cast written as a function, the same as value::date or CAST(value AS date).

See also