standardSQL:无法从时间戳中提取 DAY
standardSQL: Can't extract DAY from timestamp
我无法使用 EXTRACT()
函数从名为 repository.created_at 的时间戳变量中提取天数。
#standardSQL
SELECT repository.created_at AS fechas,
EXTRACT(DAY FROM DATE repository.created_at)
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100
如何解决?
字段 repository.created_at
的类型为 STRING。在提取日期之前,您需要将其解析为日期。
这应该有效:
SELECT repository.created_at AS fechas,
EXTRACT(DAY FROM PARSE_DATE("%Y/%m/%d",
SUBSTR(repository.created_at, 0, 10)))
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100
#standardSQL
SELECT
repository.created_at AS fechas,
EXTRACT(DAY FROM PARSE_TIMESTAMP('%Y/%m/%d %X %z', repository.created_at))
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100
我无法使用 EXTRACT()
函数从名为 repository.created_at 的时间戳变量中提取天数。
#standardSQL
SELECT repository.created_at AS fechas,
EXTRACT(DAY FROM DATE repository.created_at)
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100
如何解决?
字段 repository.created_at
的类型为 STRING。在提取日期之前,您需要将其解析为日期。
这应该有效:
SELECT repository.created_at AS fechas,
EXTRACT(DAY FROM PARSE_DATE("%Y/%m/%d",
SUBSTR(repository.created_at, 0, 10)))
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100
#standardSQL
SELECT
repository.created_at AS fechas,
EXTRACT(DAY FROM PARSE_TIMESTAMP('%Y/%m/%d %X %z', repository.created_at))
FROM `bigquery-public-data.samples.github_nested`
LIMIT 100