PostgreSQL Date Format

The following table shows the date format you can use to format a date, time, or timestamp:

PatternDescription
Y,YYYYear in 4 digits with a comma (e.g., 2,025)
YYYYYear in 4 digits (e.g., 2025)
YYYLast 3 digits of the year (e.g., 025 for 2025)
YYLast 2 digits of the year (e.g., 25 for 2025)
YLast digit of the year (e.g., 5 for 2025)
IYYYISO 8601 week-numbering year in 4 digits
IYYLast 3 digits of the ISO 8601 week-numbering year
IYLast 2 digits of the ISO 8601 week-numbering year
ILast digit of the ISO 8601 week-numbering year
BC, bc, AD, adEra indicator without periods (e.g., BC, AD)
B.C., b.c., A.D., a.d.Era indicator with periods (e.g., B.C., A.D.)
MONTHFull month name in uppercase (e.g., MARCH)
MonthFull month name with first letter capitalized (e.g., March)
monthFull month name in lowercase (e.g., march)
MONAbbreviated month name in uppercase (e.g., MAR)
MonAbbreviated month name with first letter capitalized (e.g., Mar)
monAbbreviated month name in lowercase (e.g., mar)
MMMonth number (01-12)
DAYFull weekday name in uppercase (e.g., TUESDAY)
DayFull weekday name with first letter capitalized (e.g., Tuesday)
dayFull weekday name in lowercase (e.g., tuesday)
DYAbbreviated weekday name in uppercase (e.g., TUE)
DyAbbreviated weekday name with first letter capitalized (e.g., Tue)
dyAbbreviated weekday name in lowercase (e.g., tue)
DDDDay of the year (001-366)
IDDDDay of the ISO 8601 week-numbering year (001-366)
DDDay of the month (01-31)
DDay of the week (1 = Sunday, 7 = Saturday)
IDISO 8601 day of the week (1 = Monday, 7 = Sunday)
WWeek of the month (1-5, where the first week starts on the first day of the month)
WWWeek number of the year (1-53, where the first week starts on the first day of the year)
IWISO 8601 week number of the year (01-53, where week 1 contains the first Thursday of the year)
CCCentury (e.g., 21 for years 2000-2099)
JJulian Day (integer days since November 24, 4714 BC, at noon UTC)
RMMonth in uppercase Roman numerals (I-XII; I = January, XII = December)
rmMonth in lowercase Roman numerals (i-xii; i = January, xii = December)


Was this tutorial helpful ?