google-bigquery - 如何从 Big Query 中的元表转换“creation_time”和“last_modified_time”格式列?
问题描述
我运行了查询:
选择 * 从project.dataset.__TABLES__
从特定数据集中获取我所有表的摘要。
我的问题是关于“creation_time”和“last_modified_time”列的格式。它以 13 位数字序列的格式显示日期。
有没有办法将其转换为通用日期格式?
(我期望像 YYYY-mm-dd 这样的格式)
谢谢
解决方案
该字段包含自纪元以来的毫秒数。您可以使用
TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) AS last_modified_time
获得正确的时间戳。
我正在使用类似的东西
SELECT
* REPLACE(
TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) AS last_modified_time
),
size_bytes/pow(1024,3) size_gigaBytes
FROM `project.dataset.__TABLES__`
推荐阅读
- c - 存在或不存在等待时 fork 系统调用的控制流程
- reactjs - 如何在 Next JS 中显示本地视频?
- java - Java Spring RestTemplate 从 api 获取 1 个对象
- html - 具有三角形和半透明背景的语音气泡
- c++ - 将 C 运行时的私有副本与 Windows 应用程序一起提供的最佳方式是什么
- python - 如何在 if else 中使用函数
- assembly - 组装执行顺序
- python - 是否可以在 Google Colab 上运行 Selenium?
- sql - 如何在 Postgresql 中减少所有 $0 之前创建行?
- windows - inet_ntoa UNICODE 或类似(将 IN_ADDR 转换为 UNICODE)