# to_char (number)

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: to_char (number)
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/math-functions/to-char-from-number
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/math-functions/to-char-from-number.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/math-functions/to-char-from-number.adoc
description: The TO_CHAR function formats a number into a string using a given format.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/math-functions/to-char-from-number.md -->

The `to_char` function formats a number into a string using a given format.

## [](#syntax)Syntax

The syntax for this function is:

```sql
TO_CHAR(value, format_string)
```

Parameters in the syntax include:

-   `value`: Number to format as a string.

-   `format_string`: The format of the input string.


## [](#format)Format

The format string supports these template patterns (case-insensitive):

| Pattern | Description |
| --- | --- |
| 9 | Digit position (may be dropped if insignificant) |
| 0 | Digit position (never dropped) |
| . | Decimal point |
| , | Group (thousands) separator |
| D | Decimal point |
| G | Group separator |
| S | Plus/minus sign directly before or after a number |
| PL | Plus sign in the specified position (for negative numbers) |
| MI | Minus sign in specified position (for positive numbers) |
| SG | Plus/minus sign in the specified position. |

### [](#limitations)Limitations

-   All text inside double quote `"{text}"` will not be considered a pattern.

-   The quote character `""` will not appear in the result string.

-   Any text that does not match any pattern is preserved in the result string.


## [](#examples)Examples

### [](#format-with-leading-zeros)Format with leading zeros

The query formats 123.456 with leading zeros using the pattern ‘00000.00000’.

```sql
SELECT TO_CHAR(123.456, '00000.00000');
```

The query returns:

```sql
   to_char
--------------
  00123.45600
```

### [](#format-with-variable-length)Format with variable length

The query formats the number 123.456 with a variable-length pattern ‘99999.99999’.

```sql
SELECT TO_CHAR(123.456, '99999.99999');
```

The query returns:

```sql
   to_char
--------------
    123.45600
```

### [](#format-with-group)Format with group

The query formats the number 123456 with grouping separators using the pattern ‘9,999,999,999’.

```sql
SELECT TO_CHAR(123456, '9,999,999,999');
```

The query returns:

```sql
    to_char
----------------
        123,456
```

### [](#format-with-negative-number)Format with negative number

The query formats the number -123 with a custom pattern including the sign.

```sql
SELECT TO_CHAR(-123, '"Number formatted with pattern:000S":{000S}');
```

The output shows the custom-formatted number.

```sql
                  to_char
-------------------------------------------
 Number formatted with pattern:000S:{123-}
```

### [](#format-with-sign)Format with sign

The query formats the number -123.456 with a custom pattern including the sign and separated integer.

```sql
SELECT TO_CHAR(-123.456, '"Sign is: "SG" integer part is: "999", fractional part is: ".999');
```

The query returns:

```sql
                         to_char
---------------------------------------------------------
 Sign is: - integer part is: 123, fractional part is: .456
```