PostgreSQL-the most complete string and date formatting function
First, the string and date mutual format function return type description example to_char (timestamp, text) text converts the timestamp into a string to_char (current_timestamp, 'HH12:MI:SS') to_char (interval, text) text, converts the time interval into the string to_char (interval' 15h 2m 12s, 'HH24:MI:SS') to_char (int, text) text converts integers into the string to_char '999') to_char (double precision, text) text converts real numbers / a double into strings to_char (125.8::real,' 999D9') to_char (numeric, text) text converts numeric into strings to_char (- 125.8, '999D99S') to_date (text, text) date converts strings to date to_date (' 05 Dec 2000 numbers,'DD Mon YYYY') to_timestamp (text) Text) timestamp converts strings to timestamps to_timestamp ('05 Dec 2000,'DD Mon YYYY') to_timestamp (double) timestamp, converts UNIX era to timestamps to_timestamp (200120400) to_number (text, text) numeric, converts strings to numericto_number ('12454.8' Placeholder for date / time formatting placeholder describes HH hours of day (01-12) HH12 hours of day (01-12) HH24 hours of day (00-23) MI minutes (00-59) SS seconds (00-59) MS milliseconds (000,999) US microseconds (000000-999999) AM noon logo (uppercase) Y YYY comma year (4 and more digits) YYYY year (4 and more digits) the last three digits of the YYY year, the last two Y digits of the YY year, the last MONTH full length uppercase month name (blank fill is 9 characters) Month full length mixed uppercase month name (blank fill 9 characters) month full length lowercase month name (blank fill 9 characters) MON uppercase month name (3 characters) Mon abbreviation mixed case month name Share name (3 characters) mon lowercase month name (3 characters) mm month number (01-12) DAY full length uppercase date name (blank fill is 9 characters) Day full length mixed uppercase date name (blank fill 9 characters) day full length lowercase date name (blank fill 9 characters) DY abbreviated uppercase date name (3 characters) Dy abbreviation mixed uppercase date name (3 characters) dy abbreviation lowercase date name Date name (3 characters) DDD days of the year (001-366) DD days of the month (01-31) D days of the week (1-7) Sunday is 1) W weeks of the month (1-5) (the first week begins on the first day of the month) WW weeks of the year (1-53) (the first week begins on the first day of the year)