Home > Net >  How to convert time_usec into date format on Google BigQuery?
How to convert time_usec into date format on Google BigQuery?

Time:11-01

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!

CodePudding user response:

Use below

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

CodePudding user response:

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.

  • Related