The TO_CHAR function converts an Oracle expression into a character value, formatting the output to suit your needs. Use a string template (format_mask) to define the format, including text characters, format modifiers, and placeholders. Format masks are case-sensitive, and placeholders require the correct format modifier.
Usage of TO_CHAR function in Oracle
The role of TO_CHAR function
# The ##TO_CHAR function converts the value of any expression into a character (string) value, allowing formatting and customized display of the data.Syntax
<code>TO_CHAR(expression, format_mask)</code>
Parameters
Format Mask
The format mask is a special string that specifies the format of the output character value. It contains the following elements:Usage Example
<code>TO_CHAR(12345, '99,999')</code>Output: 12,345
<code>TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS')</code>Output: 10-JAN-2023 14:35:12
<code>TO_CHAR(12345.6789, '99,999.99')</code>Output: 12,345.68
<code>TO_CHAR(12345, '99,999$" records"')</code>Output: 12,345 records
Note
The above is the detailed content of Tochar usage in oracle. For more information, please follow other related articles on the PHP Chinese website!