TO_CHAR
function formats various data types, including date/time
, integer
, float point
and numeric
into a formatted string.
TO_CHAR
function is as follows:
timestamp
: TIMESTAMP
or TIMESTAMP WITH TIMEZONE
value to be formattedformat
: format of the output stringPattern | Description |
---|---|
YYYY | Year (1-9999) |
MM | Month number (01–12) |
DD | Day of month (01–31) |
HH | Hour of day (1–12) |
HH12 | Hour of day (1–12) |
HH24 | Hour of day (0–23) |
MI | Minute (0–59) |
SS | Second (0–59) |
MS | Millisecond (0–999) |
US | Microsecond (0–999999) |
AM , am , PM or pm | Meridiem indicator without periods |
A.M. , a.m. , P.M. or p.m. | Meridiem indicator with periods |
"{text}"
will not be considered a pattern"
) will not appear in the result stringTO_CHAR
function for intervals, it is important to be aware of the following overflow restrictions:
Conversion | Source Component | Target Component |
---|---|---|
Days to Months | Days | Months |
Hours to Days | Hours | Days |
Seconds to Days | Seconds | Days |