---
title: "Format Masks"
description: "A format mask of to_char, to_date, is_date and to_number is read element by element, as in Oracle."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/general/format-masks
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/general/format-masks
updated: 2026-11-05T00:00:00Z
license: https://documentation.invantive.eu/en/
---

The functions [[TO_CHAR]], [[TO_DATE]], [[IS_DATE]] and [[TO_NUMBER]] take a format mask, such as `YYYY-MM-DD HH24:MI` for a date or `FM999G990D00` for a number. A format mask is read element by element, as in Oracle. Elements can be combined freely with punctuation and with text between double quotes, such as `"T"`. Letters of an element are recognised in any case.

Available from release 28.0. Up to and including release 27.0 only the whole masks listed under "Masks of Earlier Releases" were supported, `to_char` of a number with a mask was refused, and `to_number` ignored its mask.

## Datetime Elements

A datetime mask consists of the following elements:
- `YYYY`, `YYY`, `YY`, `Y`: year in 4, 3, 2 or 1 digits.
- `Y,YYY`: year with a comma after the thousands.
- `SYYYY`: year with a position for the sign.
- `RRRR`, `RR`: year; when reading a two-digit year, a year of 50 to 99 falls in the previous century while the current year is 0 to 49 within its century, and a year of 0 to 49 in the next century while the current year is 50 to 99.
- `IYYY`, `IYY`, `IY`, `I`: year according to [ISO 8601](https://www.iso.org/standard/70907.html), in 4, 3, 2 or 1 digits.
- `IW`: week of the year according to ISO 8601.
- `WW`: week of the year, the first week starting on 1 January.
- `W`: week of the month, the first week starting on the first day of the month.
- `CC`, `SCC`: century, the second with a position for the sign.
- `Q`: quarter.
- `MM`: month number.
- `MON`: abbreviated month name, such as `AUG`.
- `MONTH`: month name, such as `AUGUST`, padded with blanks to 9 characters.
- `MMM`: abbreviated month name in the language of the operating system, as the masks of earlier releases gave it.
- `RM`: month in Roman numerals, such as `VIII`, padded with blanks to 4 characters.
- `DD`: day of the month.
- `DDD`: day of the year.
- `D`: day of the week according to ISO 8601, Monday being 1.
- `DAY`: name of the day, such as `THURSDAY`, padded with blanks to 9 characters.
- `DY`: abbreviated name of the day, such as `THU`.
- `J`: Julian day number, the number of days since 1 January 4712 BC.
- `HH24`: hour on a 24-hour clock.
- `HH`, `HH12`: hour on a 12-hour clock.
- `AM`, `PM`, `A.M.`, `P.M.`: indicator before or after noon.
- `MI`: minutes.
- `SS`: seconds.
- `SSSSS`: seconds since midnight.
- `FF1` to `FF9`: fraction of a second in 1 to 9 digits, truncated; `FF` gives 6 digits.
- `X`: the decimal separator, a period.
- `TZH`, `TZM`: hours and minutes of the time zone offset.
- `AD`, `BC`, `A.D.`, `B.C.`: era.
- `FM`: switches fill mode on or off for the elements that follow; in fill mode numbers have no leading zeros and names no trailing blanks.
- `FX`: switches exact matching on or off when reading a text.

The case of a name follows the case of the element: `MONTH` gives `AUGUST`, `Month` gives `August` and `month` gives `august`. Names are in English.

When reading a text, without `FX`:
- any punctuation in the text matches the punctuation of the mask,
- a number may have fewer digits than its element,
- `MM` also accepts a month name and `MON` also accepts a full month name,
- the text may end before time elements at the end of the mask, which are then zero.

A missing year or month is the current one, a missing day is the first of the month. The elements `IYYY`, `IW`, `Q`, `W`, `WW` and `CC` can only format a date and are refused when reading one.

## Number Elements

A number mask consists of the following elements:
- `9`: a digit; a leading zero is a blank.
- `0`: a digit; from the leftmost `0` onwards leading zeros are shown.
- `,`, `G`: group separator, a comma.
- `.`, `D`: decimal separator, a period.
- `$`: a dollar sign before the number.
- `S`: a plus or minus sign, at the start or at the end of the mask.
- `MI`: a minus sign after a negative number, at the end of the mask.
- `PR`: a negative number between angle brackets, at the end of the mask.
- `EEEE`: scientific notation, such as `1.23E+03`.
- `V`: multiplies by 10 to the power of the number of digits after it.
- `X`: a hexadecimal digit; precede with `0` for leading zeros.
- `RN`, `rn`: Roman numerals in capitals or lower case.
- `TM`, `TM9`, `TME`: the shortest text, in decimal or in scientific notation.
- `FM`: fill mode at the start of the mask; no leading and trailing blanks, and no trailing zeros at a `9` of the fraction.

Without `FM` the text has the full width of the mask plus one position for the sign, so `to_char(5, '900')` gives `'  05'` and `to_char(5, 'FM900')` gives `'05'`. A number that does not fit the mask gives `#` over the full width. The elements `B`, `C`, `L` and `U` depend on national settings and are not supported.

`to_number` reads a text by the mask. A text that does not match the mask is read as in earlier releases: as a number with a period as decimal separator and commas as group separators.

## Masks of Earlier Releases

The following whole masks were supported up to and including release 27.0. They keep exactly the output of earlier releases, even where that differs from Oracle, such as the culture-dependent separators of `YYYY/MM/DD HH24:MI:SS` and the 24-hour clock of `MONTH DD, YYYY HH:MI AM`:
- `YYYY`, `YYYYMM`, `YYYY-MM`, `MM`, `MM-YYYY`,
- `YYYYMMDD`, `YYYY-MM-DD`, `YYYY/MM/DD`, `DDMMYYYY`, `MMDDYYYY`, `MMDDYY`,
- `DD-MM-YY`, `DD/MM/YY`, `MM-DD-YY`, `MM/DD/YY`, `DD-MM-YYYY`, `DD/MM/YYYY`, `MM-DD-YYYY`, `MM/DD/YYYY`,
- `DD-MMM-YY`, `DD/MMM/YY`, `DD-MMM-YYYY`, `DD/MMM/YYYY`,
- `YYYYMMDDHH24MI`, `YYYYMMDDHH24MISS`, `YYYY-MM-DD HH24:MI:SS`, `YYYY/MM/DD HH24:MI:SS`,
- `DD-MM-YYYY HH24:MI:SS`, `DD/MM/YYYY HH24:MI:SS`, `MM-DD-YYYY HH24:MI:SS`, `MM/DD/YYYY HH24:MI:SS`, `DD/MMM/YYYY HH24:MI:SS`,
- `YYYY-MM-DD"T"HH24:MI:SS"Z"`, `YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"`,
- `HH24MI`, `HH24:MI`, `HH24MISS`, `HH24:MI:SS`,
- `MONTH DD, YYYY HH:MI AM`,
- `YYYYIW`, `YYYY-IW`, `IW`, `D`.

## Examples

The following example formats a timestamp without seconds:
```sql
select to_char(timestamp '2026-08-13 12:34:56', 'YYYY-MM-DD HH24:MI')

-------------------
2026-08-13 12:34
```
The following example formats a date with the names of day and month:
```sql
select to_char(date '2026-03-05', 'FMDay DD Month YYYY')

-------------------
Thursday 5 March 2026
```
The following example reads a date with a month name and a time without seconds:
```sql
select to_date('13-Aug-2026 12:34', 'DD-MON-YYYY HH24:MI')

-------------------
13-08-2026 12:34:00
```
The following example formats a number with group and decimal separators:
```sql
select to_char(1234567.891, 'FM999G999G990D00')

-------------------
1,234,567.89
```
The following example reads a negative amount between angle brackets:
```sql
select to_number('<123.45>', '999D99PR')

-------------------
-123.45
```
