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?

>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')

Leave a Reply