How to Format Dates in PostgreSQL

Last updated July 25, 2026 · By the SaturnSQL team

Use to_char(value, 'pattern') to format dates and timestamps as text. Common pattern parts: YYYY, MM, DD, HH24, MI, SS, Mon, Day, and FM to strip padding.

SELECT
  to_char(created_at, 'YYYY-MM-DD')          AS iso_date,
  to_char(created_at, 'DD Mon YYYY')          AS readable,
  to_char(created_at, 'YYYY-MM-DD HH24:MI')   AS with_time,
  to_char(created_at, 'FMDay, FMDD FMMonth')  AS long_form
FROM orders
LIMIT 5;

to_char returns text, so use it only for display; for grouping or comparisons keep native date/timestamp types (e.g. date_trunc('month', created_at)). FM before a pattern removes the blank-padding Postgres adds to Day and Month names.

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related PostgreSQL guides

© 2026 Panda Capital Oy Ab. All rights reserved.