Mishal
Mishal

Reputation: 430

How to convert time_usec into date format on Google BigQuery?

I've the below column,

enter image description here

and I'd like to get the date in yyyy-mm-dd format from the time_usec column.

enter image description here

Any guidance is appreciated!

Upvotes: 0

Views: 3293

Answers (2)

Kolban
Kolban

Reputation: 15266

One possible solution would be the following:

SELECT 
   TIMESTAMP_ADD(TIMESTAMP "1970-01-01 00:00:00+00",
      INTERVAL 1635500264544000 MICROSECOND) AS t1;

Here we use the TIMESTAMP_ADD function to add the microseconds value to the base epoch.

Upvotes: 1

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172994

Use below

select time_usec, date(timestamp_micros(time_usec)) date
from your_table

Upvotes: 2

Related Questions