Skip to content
Advertisement

parse_timestamp vs format_timestamp bigquery

Could someone help me understand why these two queries are returning different results in bigquery?

select FORMAT_TIMESTAMP('%F %H:%M:%E*S', "2018-10-01 00:00:00" , 'Europe/London')
returns 2018-10-01 01:00:00

select PARSE_TIMESTAMP('%F %H:%M:%E*S', "2018-10-0100:00:00", "Europe/London")
returns 2018-09-30 23:00:00 UTC

As 2018-10-01 is during british summer time (UTC +1), I would’ve expected both queries to return 2018-09-30 23:00:00 UTC

Advertisement

Answer

The first is given a timestamp which is in UTC. It then converts it to the corresponding time in Europe/London. The return value is a string representing the time in the local timezone.

The second takes a string representation and returns a UTC timestamp. The representation is assumed to be in Europe/London.

So, the two functions are going in different directions, one from UTC to the local time and the other from the local time to UTC.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement