TO_CHAR()

Description of to_char_number.eps follows

TO_CHAR(value[, format_mask][, nls_language])

value:

a number or date that will be converted to a string\

format_mask:

Optional. This is the format that will be used to convert the value to a string.

nls_language:

Optional.  This is an optional argument that allows you to specify National Language Support (NLS) parameters to influence the format. It’s commonly used to define the language, date format, and other regional settings.

  • TO_CHAR (number) converts n to a value of VARCHAR2 data type, using the optional number format fmt
  • The value n can be of type NUMBER, BINARY_FLOAT, or BINARY_DOUBLE
  • If you omit fmt, then n is converted to a VARCHAR2 value exactly long enough to hold its significant digits
  • TO_CHAR is a way to explicity convert format
  • By default, TO_CHAR leaves a space for numbers. You can use the LTRIM() function to remove it, if necessary.

Converting Dates To Strings

-- USE THE TO_CHAR() TO CONVERT DATES
SELECT 'Today is ' || TO_CHAR(CURRENT_DATE, 'DD-MM-YYYY') AS WOW
FROM DUAL;

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top