首页 > 解决方案 > 如何在 Amazon Athena 中获取数据中的左十个字符

问题描述

我正在尝试创建一个包含日期最左边 10 个字符的视图,因为我不需要小时、分钟、秒。

我试过左边的查询,但说不支持这种查询。

CREATE OR REPLACE VIEW generated_date AS SELECT left("generation_date", 10) FROM database_final

我预计 2019/02/08 但它最初是 2019/02/08 12:00:00

标签: amazon-web-servicesamazon-athenapresto

解决方案


SUBSTR("generation_date", 1, 10)将为您提供字符串的前 10 个字符。

您可以在此处找到 Athena 支持的所有字符串函数:https ://prestodb.github.io/docs/0.172/functions/string.html


推荐阅读