Skip to main content

Celonis Product Documentation

TO_STRING
Description

TO_STRING converts INT or DATE input to STRING output. For DATE input, the output format needs to be specified.

Supported input: DATE, INT.

Output column type: STRING.

Syntax
 TO_STRING ( table.column [, FORMAT ( format ) ] ) 
FORMAT syntax

The <format> defines how the input DATE should be converted.

The following special fields in <format> are supported:

  • %Y: 4-digit year.

  • %m: 2-digit month of year.

  • %d: 2-digit day of month.

  • %H: 2-digit hour of day in 24-hour format.

  • %M: 2-digit minutes per hour.

  • %S: 2-digit seconds per minute.

  • %%: A literal "%" character.

All other FORMAT content are copied to the output STRING.

Null handling

If the input value is NULL, the output value is NULL as well.

Examples

[1]

Convert integers to strings. NULL input is also NULL in the output:

Query

Column1

         TO_STRING ( "Table1"."Column1" )
        

Input

Output

Table1

Column1 : int

null

0

100

-200

-9223372036854775808

9223372036854775807

Result

Column1 : string

null

'0'

'100'

'-200'

'-9223372036854775808'

'9223372036854775807'

[2]

Example in which a DATE constant is converted to a STRING type. Leading zero is added.

Query

Column1

         TO_STRING ( {t 0 } , FORMAT ( '%Y-%m-%d %H:%M:%S' ) )
        

Input

Output

Result

Column1 : string

'1970-01-01 00:00:00'

[3]

Example in which DATE values are converted to STRING types. NULL values are mapped to NULL values.

Query

Column1

         TO_STRING ( "Table"."Dates" , FORMAT ( '%m-%d-%Y, %H,%M,%S' ) )
        

Input

Output

Table

Dates : date

Thu Mar 15 1979 23:31:42.000

null

Tue Aug 24 2021 12:52:31.000

Sun Dec 01 2019 14:13:22.000

Fri Nov 22 1991 11:22:33.000

Result

Column1 : string

'03-15-1979, 23,31,42'

null

'08-24-2021, 12,52,31'

'12-01-2019, 14,13,22'

'11-22-1991, 11,22,33'

See also: