I'd like to perform a join between two tables using the date column. However, since they come from two different dataset, the tables use two different formats:
Table_1 -> date: 2020-04-23 17:00:00 UTC
Table 2 -> date: 2020-04-11
Is there a way to do this in BigQuery in standard SQL?
Date columns do not have different formats. date
is a built-in data type. But there are three types for storing date/times: date
, datetime
, and timestamp
.
You can convert datetime
and timestamp
s to dates. That allows you to do:
from table_1 t1 join
table_2 t2
on date(t2.timestamp) = t1.date
You may want to include a timezone specified in the logic as well, but your question does not reference this. It assumes the days are UTC as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.