[英]How do I convert a datetime to a date in Google Bigquery using standard SQL or how do I extract the year in a where statement from datetime?
[英]How I can extract year from a date in sql and use it in where clause
我在名為released_date
的表中有一個日期列,其數據格式例如: 01-Jan-1995
。 我只想擁有大於1997
的年份。 有人知道我怎么寫這樣的查詢嗎?
嘗試這個:
SELECT * FROM table_name WHERE year(released_date) > 1997
如果日期是 dd-MMM-yyyy 格式,您可以使用 regexp_extract:
select regexp_extract (released_date, '(\\d{4})$',1) as year
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.