09 June 2019 · victor ·       Add to Favorites   Report

BigQuery automatically converts timestamp timezone to UTC

Here's my source data:

Once i load the data into my bigquery table, it automatically converts the timestamp to UTC:

How do I get the second column to be in eastern time?

Solution:

You can "transform" first column into eastern time on-fly - something like in below example

#standardSQL
WITH t AS (
  SELECT TIMESTAMP '2018-05-07 22:40:00+00:00' AS ts
)
SELECT ts, STRING(ts, '-04:00') timestamp_eastern
FROM t

You can create view which will consists of all the logic you need in place so client will query that view instead of original table

#standardSQL
CREATE VIEW `project.dataset.your_view` AS 
SELECT ts, STRING(ts, '-04:00') timestamp_eastern 
FROM `project.dataset.your_table`

victor

posted on 09 June 2019

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied