TO_STRING function - Amazon Quantum Ledger Database (Amazon QLDB)

TO_STRING function

Returns a string representation of a given timestamp in the specified format pattern.

Syntax

TO_STRING ( timestamp, 'format' )

Arguments

timestamp

The field name or expression of data type timestamp that the function converts to a string.

An Ion timestamp literal value can be denoted with backticks (`...`). For formatting details and examples of timestamp values, see Timestamps in the Amazon Ion specification document.

format

The string literal that specifies the format pattern of the result, in terms of its date parts. For valid formats, see Timestamp format strings.

Return type

string

Examples

TO_STRING(`1969-07-20T20:18Z`, 'MMMM d, y') -- "July 20, 1969" TO_STRING(`1969-07-20T20:18Z`, 'MMM d, yyyy') -- "Jul 20, 1969" TO_STRING(`1969-07-20T20:18Z`, 'M-d-yy') -- "7-20-69" TO_STRING(`1969-07-20T20:18Z`, 'MM-d-y') -- "07-20-1969" TO_STRING(`1969-07-20T20:18Z`, 'MMMM d, y h:m a') -- "July 20, 1969 8:18 PM" TO_STRING(`1969-07-20T20:18Z`, 'y-MM-dd''T''H:m:ssX') -- "1969-07-20T20:18:00Z" TO_STRING(`1969-07-20T20:18+08:00Z`, 'y-MM-dd''T''H:m:ssX') -- "1969-07-20T20:18:00Z" TO_STRING(`1969-07-20T20:18+08:00`, 'y-MM-dd''T''H:m:ssXXXX') -- "1969-07-20T20:18:00+0800" TO_STRING(`1969-07-20T20:18+08:00`, 'y-MM-dd''T''H:m:ssXXXXX') -- "1969-07-20T20:18:00+08:00" -- Runnable statements SELECT TO_STRING(`1969-07-20T20:18Z`, 'MMMM d, y') FROM << 0 >> -- "July 20, 1969" SELECT TO_STRING(`1969-07-20T20:18Z`, 'y-MM-dd''T''H:m:ssX') FROM << 0 >> -- "1969-07-20T20:18:00Z"

Related functions