Apache Hive - 获取上个月的最后一天

问题描述 投票:0回答:1

使用 Apache Hive,我尝试使用系统 current_date 获取上个月的最后一天。我可以使用 last_day(current_date) 找到当前月份的最后一天,但我需要上个月。我尝试过使用 add_months(-1) 和 date_add 到 current_date,但这给了我一个错误,指出该函数不存在。

期待上个月的最后一天

hive
1个回答
0
投票

我尝试了以下方法,效果很好。

select last_day(add_months(current_date, -1));

enter image description here

如果这不能解决您的问题,请分享查询、错误和 Hive 版本

© www.soinside.com 2019 - 2024. All rights reserved.