我想在Bigquery中將拼寫出來的星期幾和月份轉換爲時間戳記格式。如何在BigQuery中以字符串格式拼寫出工作日月份?
我的日期目前存儲爲Mon Jul 27 07:08:00 +0000 2015
,我想將它們轉換爲2015-07-27 07:08:00 UTC
我已閱讀答案從How do I cast dd/mm/yyyy string into date in BigQuery?,並試圖對其進行格式化下列方式
SELECT TIMESTAMP(year + '-' + month + '-' + day) as output_timestamp
FROM (
SELECT
REGEXP_EXTRACT(created_at, '.*/([0-9]{4})$') as year,
REGEXP_EXTRACT(created_at, '^([0-9]{2}).*') as day,
REGEXP_EXTRACT(created_at, r'(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)') AS month
)
[dataset.tablename] where collected_at = "2016-01-01 00:00:01" LIMIT 100
不過,我得到這個錯誤query: SELECT query which references non constant fields or uses aggregation functions or has one or more of WHERE, OMIT IF, GROUP BY, ORDER BY clauses must have FROM clause. (error code: invalidQuery)
如何將其轉換爲我想要的格式?
太謝謝你了。對於那些可能嘗試這樣做的人,您還需要取消選中SQL版本使用舊版SQL,以便此代碼可以工作。否則你會得到'bigquery錯誤:2.24 - 2.84'。 – Avi