Amazon Athena 将字符串转换为日期

Amazon Athena Convert String to Date

我希望将以下字符串:mmm-dd-yyyy 转换为日期:yyyy-mm-dd

例如

2015 年 11 月 6 日至 2015 年 11 月 6 日

在 Amazon Athena 中

我愿意date_parse。相应地调整您的正则表达式。

select date_parse('Nov-06-2015','%b-%d-%Y')

2015-11-06 00:00:00.000

refd:https://prestodb.io/docs/current/functions/datetime.html

您还可以使用 cast 函数将所需输出作为日期类型。

select cast(date_parse('Nov-06-2015','%M-%d-%Y') as date);

输出--2015-11-06

在亚马逊雅典娜 https://prestodb.io/docs/current/functions/datetime.html 使用日期解析来解析字符串并转换为 2015-11-06 00:00:00.000 进入 2015-11-06