event_date
包含存储为字符串的时间戳。
1382623200
1382682600
1384248600
...
SELECT
哪些行event_date
小于字符串格式的日期?这是我最好的尝试:
SELECT *
FROM [analytics:workspace.events]
WHERE TIMESTAMP(event_date) < PARSE_UTC_USEC("2013-05-02 09:09:29");
无论我传递给PARSE_UTC_USEC()
答案 0 :(得分:0)
请尝试以下操作。希望这有帮助
SELECT event_date, TIMESTAMP(event_date) as ts
FROM -- [analytics:workspace.events]
(
SELECT event_date FROM
(SELECT '1382623200' AS event_date),
(SELECT '1382682600' AS event_date),
(SELECT '1384248600' AS event_date)
)
WHERE TIMESTAMP(event_date) < PARSE_UTC_USEC("2013-10-25 07:30:00")
以上只是示例 - 您应该在现实生活中使用您的表格:
SELECT event_date, TIMESTAMP(event_date) as ts
FROM [analytics:workspace.events]
WHERE TIMESTAMP(event_date) < PARSE_UTC_USEC("2013-10-25 07:30:00")
答案 1 :(得分:0)
看起来event_date
字符串代表Unix秒。使用standard SQL(取消选中“显示选项”下的“使用旧版SQL”)尝试此操作:
WITH T AS (
SELECT x, event_date
FROM UNNEST(['1382623200',
'1382682600',
'1384248600']) AS event_date WITH OFFSET x
)
SELECT *
FROM (
SELECT * REPLACE (TIMESTAMP_SECONDS(CAST(event_date AS INT64)) AS event_date)
FROM T
)
WHERE event_date < '2013-05-02 09:09:29';
子查询使用event_date
子句将REPLACE
字符串转换为时间戳。