Date and Time Functions

date_from_datetime

date_from_datetime( datetime, expr )

Converts a datetime datatype to a date in a specified time zone. This function accepts any standard TZ timezone Database label.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    date_from_datetime(my_datetime_column, literal 'America/New_York') as my_new_date_column
from original_table;

datetime_from_date

datetime_from_date( date, expr )

Converts a date datatype to a datetime in a specified time zone. This function accepts any standard TZ timezone Database label.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    date_from_datetime(my_datetime_column, literal 'America/New_York') as my_new_date_column
from original_table;

local_datetime

local_datetime( datetime, expr )

Converts a UTC datetime to a datetime in a specified time zone. This function accepts any standard TZ timezone Database label.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    local_datetime(my_datetime_column, literal 'America/New_York') as my_new_datetime_column
from original_table;

print_date( date, expr )

Provides a new string value from a date value. This function uses JODA-style date formats.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    print_date(my_datetime_column, literal 'Y-M-d') as switchboard_processing_time
from original_table;

processing_datetime

processing_datetime()

Provides the UTC datetime stamp when the data pipeline was processed.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    processing_datetime() as switchboard_processing_time
from original_table;

utc_datetime

utc_datetime( expr )

Converts a datetime value from local timezone to UTC. Requires the local timezone as either an offset or a standard TZ timezone Database label.

table new_table_with_processing_datetime_column is select
	column1,
	column2,
    utc_datetime(my_datetime_column, literal "US/Pacific") as my_utc_datetime_column
from original_table;