Skip to main content
← PL/SQL Topics

String & Data Functions

Explain TO_CHAR, TO_DATE and TO_NUMBER format models

TO_CHAR, TO_DATE and TO_NUMBER Format Models

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

A format model is a string of codes that maps between a DATE/NUMBER and its text representation.

How it works

TO_CHAR(value, 'format') renders a date or number as text; TO_DATE(text, 'format') and TO_NUMBER(text, 'format') parse text back. Common date codes: YYYY, MM, MON, DD, HH24, MI, SS. Common number codes: 9 (digit, blank if leading zero), 0 (digit, always shown), FM (trim padding), 999G999D99 (locale group/decimal), L (local currency). Always pass an explicit format instead of relying on NLS defaults.

How it works
SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS')          AS ts,
       TO_CHAR(1234567.5, 'FM999G999G990D00')             AS money,
       TO_DATE('2026-08-27', 'YYYY-MM-DD')                AS parsed_date,
       TO_NUMBER('1.234,56', '9G999D99',
                 'NLS_NUMERIC_CHARACTERS='',.''')         AS parsed_num
  FROM dual;

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI