format_time

Description

Format a timestamp column according to the specified format string.

Format specifiers are detailed in Snowflake’s time format specifiers documentation

format_time can be used to extract elements of a time, such as the year or hour.

Timezone is always assumed to be UTC.

Return type

string

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

format_time(time, format)

Argument

Type

Optional

Repeatable

Restrictions

time

timestamp

no

no

none

format

string

no

no

constant

Examples

make_col year:format_time(@."Valid From", "YYYY")

Extracts the year from the “Valid From” column

make_col formatted:format_time(@."Valid From", 'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM')

Format the “Valid From” column according to ISO 8601

make_col formatted:format_time(@."Valid From", 'DY MON DD HH24:MI:SS YYYY')

Format the “Valid From” column similar to ctime’s format

make_col formatted:format_time(@."Valid From", 'MM/DD/YYYY HH12:MI:SS')

Format the “Valid From” column using US’s date format and a 12-hour clock.