PostgreSQL 18 reference · Date and Time Functions

PostgreSQL TO_CHAR() Function

Format a date, timestamp or number as text with a pattern such as 'DD Mon YYYY' or 'FM999,990.00'.

PostgreSQL 18

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

Syntax

to_char(value, format)

Parameters

ParameterDescription
value A timestamp, date, interval or number.
format Date codes: YYYY MM DD Mon Day HH24 MI SS; number codes: 9 digit, 0 forced digit, . , FM (no padding).

Return value

Text.

Examples

Format dates
SELECT to_char(DATE '2026-03-09', 'DD Mon YYYY') AS uk,
       to_char(TIMESTAMP '2026-03-09 07:45', 'FMDay, HH24:MI') AS weekday_time;

Output

     uk      | weekday_time
-------------+---------------
 09 Mar 2026 | Monday, 07:45
(1 row)

Run this on your computer — see “Get Started” for setup.

Format numbers
SELECT to_char(1234567.891, 'FM9,999,999.00') AS money,
       to_char(7, 'FM000') AS padded;

Output

    money     | padded
--------------+--------
 1,234,567.89 | 007
(1 row)

Run this on your computer — see “Get Started” for setup.

In other languages

Was this page helpful?