TO_CHAR function in Oracle

TO_CHAR is one of the vital Conversion functions of Oracle. It is used to convert a number or date to a string. The TO_CHAR function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.

Syntax:

TO_CHAR ( value, format_mask, nls_language )

Parameters:
value: It is used to specify the number or date to be converted.
format_mask: It is an optional parameter which is used to specify the format to be used for conversion.
nls_language: It is an optional parameter which is used to specify the nls language to be used for conversion.

Example 1:

TO_CHAR(1340.64, '9999.9')

Output:

 ' 1340.6'

Explanation:
Here, a number is converted to a string in the desired format.

Example 2:

TO_CHAR(sysdate, 'Month DD, YYYY')

Output:

 'June 28, 2019'

Explanation:
Here, a date value is converted to a string in the desired format.