PostgreSQL 18 reference · Date and Time Functions
PostgreSQL TO_DATE() Function
Parse text into a date using a format pattern, such as to_date('09/03/2026', 'DD/MM/YYYY').
PostgreSQL 18
Syntax
to_date(text, format)
Parameters
| Parameter | Description |
|---|---|
text |
The date as text. |
format |
The pattern the text follows. |
Return value
date.
Examples
SELECT to_date('09/03/2026', 'DD/MM/YYYY') AS d,
to_date('March 9, 2026', 'Month DD, YYYY') AS d2;
Output
d | d2 ------------+------------ 2026-03-09 | 2026-03-09 (1 row)
Run this on your computer — see “Get Started” for setup.
SELECT '2026-03-09'::date AS iso_needs_no_pattern;
Output
iso_needs_no_pattern ---------------------- 2026-03-09 (1 row)
Run this on your computer — see “Get Started” for setup.
Related
TO_TIMESTAMP()· Convert Unix epoch seconds to a timestamp with time zone, or parse text into one with a format pattern.TO_CHAR()· Format a date, timestamp or number as text with a pattern such as 'DD Mon YYYY' or 'FM999,990.00'.MAKE_DATE()· Build a date from year, month and day numbers. make_timestamp() and make_time() do the same for other types.- SQL Date Functions · tutorial