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 Jun 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds