Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

BigQuery: invalid time zone with UTC+5.5

The data we have involves a Time column and a timezone column. Unfortunately, some of the timezones are UTC-offsets that are funky, as below:

SELECT DATETIME(TIMESTAMP '2008-12-25 15:30:00', "UTC+5.5") AS my_time;

Invalid time zone: UTC+5.5

Removing the 0.5 works, but this is not ideal…

SELECT DATETIME(TIMESTAMP '2008-12-25 15:30:00', "UTC+5") AS my_time;
2008-12-25T20:30:00

Any thoughts on how to convert a timestamp to a timezone aware timestamp with a 0.5 Offset?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You might consider below.

-- sample data
WITH sample_data AS (
  SELECT TIMESTAMP '2008-12-25 15:30:00' time, "UTC+5" timezone
   UNION ALL
  SELECT TIMESTAMP '2008-12-25 15:30:00' time, "UTC+5.5" timezone
)
-- query starts here
SELECT SAFE.DATETIME(time, REGEXP_REPLACE(timezone, r'\.5$', r':30')) my_time
  FROM sample_data

-- query result
+---------------------+
|       my_time       |
+---------------------+
| 2008-12-25T20:30:00 |
| 2008-12-25T21:00:00 |
+---------------------+
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading