Format timestamp as string

Supported in: Batch, Streaming

Returns the timestamp as a formatted string (ISO8601 by default).

Expression categories: Cast, Datetime, String

Declared arguments

  • Timestamp - The timestamp to convert to a string.
    Expression<Timestamp>
  • optional Format - The format to use, defaults to ISO8601 with a zone offset.
    Literal<String>
  • optional Time zone - Defaults to UTC.
    TimeZone

Output type: String

Examples

Example 1: Base case

Argument values:

  • Timestamp: 2022-10-01T09:00:00Z
  • Format: yyyy-MM-dd
  • Time zone: null

Output: 2022-10-01


Example 2: Base case

Argument values:

  • Timestamp: 2022-10-01T09:00:00Z
  • Format: yyyy-MM-dd-hh-mm-ss
  • Time zone: EST

Output: 2022-10-01-04-00-00


Example 3: Null case

Argument values:

  • Timestamp: null
  • Format: yyyy-MM-dd
  • Time zone: UTC

Output: null


Example 4: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm XXXX
  • Time zone: EST

Output: 10-00 -0500


Example 5: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm X
  • Time zone: EST

Output: 10-00 -05


Example 6: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm X
  • Time zone: null

Output: 15-00 Z


Example 7: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm O
  • Time zone: EST

Output: 10-00 GMT-5


Example 8: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm-ss-SS
  • Time zone: null

Output: 15-00-01-00


Example 9: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm v
  • Time zone: EST

Output: 10-00 -05:00


Example 10: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm z
  • Time zone: EST

Output: 10-00 -05:00


Example 11: Edge case

Argument values:

  • Timestamp: 2022-10-01T09:00:00Z
  • Format: hh-mm-a
  • Time zone: null

Output: 09-00-AM


Example 12: Edge case

Argument values:

  • Timestamp: 2022-10-01T09:00:00Z
  • Format: KK-mm-a
  • Time zone: null

Output: 09-00-AM


Example 13: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:00Z
  • Format: kk-mm-a
  • Time zone: null

Output: 15-00-PM


Example 14: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:00Z
  • Format: HH-mm-a
  • Time zone: null

Output: 15-00-PM


Example 15: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm xxxx
  • Time zone: EST

Output: 10-00 -0500


Example 16: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm x
  • Time zone: EST

Output: 10-00 -05


Example 17: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm x
  • Time zone: null

Output: 15-00 +00


Example 18: Edge case

Argument values:

  • Timestamp: 2022-10-01T15:00:01Z
  • Format: HH-mm Z
  • Time zone: EST

Output: 10-00 -0500