Google bigquery 使用大于符号比较BQ中的日期

Google bigquery 使用大于符号比较BQ中的日期,google-bigquery,Google Bigquery,大于符号用于比较日期,这样使用或任何其他可用解决方案是否正确 #standardSQL with table1 as( select "ProductA" as products, date '2017-1-20' as end_date union all select "ProductB" as products, date '2017-6-20' as end_date union all select "ProductC" as products, date '2018-1-20' as

大于符号用于比较日期,这样使用或任何其他可用解决方案是否正确

#standardSQL
with table1 as(
select "ProductA" as products, date '2017-1-20' as end_date union all
select "ProductB" as products, date '2017-6-20' as end_date union all
select "ProductC" as products, date '2018-1-20' as end_date union all
select "ProductD" as products, date '2018-6-20' as end_date
)
select products,end_date,if(current_date()>end_date,'outdated','current') status from table1
下面是使用函数DATE_SUB获得相同结果的另一种方法。
有许多不同的数据类型可供使用。“>”可以处理许多数据类型,包括该类型。

当然,这是可行的,您很可能已经知道这一点,只需运行示例并查看结果即可。那么你为什么要问——在你的例子中,应该有一些不可见的东西驱使你问你的问题:o)
SELECT products,end_date, if(DATE_SUB(current_date(), INTERVAL 1 DAY)>end_date,'outdated','current') status from table1;