在 bigquery 中将 DATETIME 格式转换为自定义格式

Neh*_*908 2 sql python-2.7 google-bigquery

我有一个列BigQueryDATETIME例如2018-08-16T11:00:35.683000,我想在一些自定义的格式,它是转换YYYY-MM-dd HH:MM。我怎样才能做到这一点 ?转换时出现以下错误:

ValueError:时间戳超出平台 localtime()/gmtime() 函数的范围

Mik*_*ant 5

下面是 BigQuery 标准 SQL 的示例

#standardSQL
WITH `project.dataset.table` AS (
  SELECT DATETIME '2018-08-16T11:00:35.683000' dt
)
SELECT FORMAT_DATETIME('%Y-%m-%d %R', dt) cust_dt
FROM `project.dataset.table`  
Run Code Online (Sandbox Code Playgroud)

结果

Row cust_dt  
1   2018-08-16 11:00     
Run Code Online (Sandbox Code Playgroud)