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

Get correct timestamp from a column SQL Bigquery

I’m new to SQL BQ. I have logs in which timestamp is in the format:

2023-01-03T18:00:39.615375452Z
2023-01-03T19:00:39.615375452Z
2023-01-03T20:00:39.615375452Z

I have to convert the column to timestamp using the timestamp function but I get error Invalid timestamp .

Any quick or elegant way of extracting timestamp from the column?

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 can try using the parse_timestamp function in BQ:

Syntax:

PARSE_TIMESTAMP(format_string, timestamp_string[, time_zone])

SELECT PARSE_TIMESTAMP('%FT%H:%M:%E*SZ', '2023-01-03T16:00:05.909896168Z')

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