TO_CHAR(valueIN { smallint | int | bigint | real | double precision | numeric | text | timestamp | timestamptz } [, fmt IN text])RETURNStext
Overview
The TO_CHAR function converts a number, date, timestamp, or string value to a string according to the format model (fmt) specified.
If no format model is provided, each data type is converted to a string according to its default output format.
For numeric types, integers, floating point numbers, and numeric values are converted according to the format.
Dates and timestamps are converted to the specified format (e.g., 'YYYY-MM-DD', 'HH24:MI:SS').
Parameter
Parameter
Description
value
smallint | int | bigint | real | double precision | numeric | text | timestamp | timestamptz
The target value to convert. This can be numbers, dates, timestamps, or string values. For text type, the fmt argument is not available, and you must use the mouth Returns the received string as is.
fmt
text type; It is a format model that specifies the output format. For example, numbers can be specified as ‘FM9999’, and dates/times can be specified as ‘YYYY-MM-DD HH24:MI:SS’.