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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

to_date(text, format)

Parameters

ParameterDescription
text The date as text.
format The pattern the text follows.

Return value

date.

Examples

Parse dates
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.

ISO dates can just be cast
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.

Was this page helpful?