【发布时间】:2021-12-18 19:33:52
【问题描述】:
我不确定这是否只是在我的本地实例上,或者它是否是一个基本问题,但对我来说,hive date_format 在 2021 年 12 月 25 日之后一年跳跃。
Select date_format('2021-12-25','YYYY-MM-dd') as Correct2021
,date_format('2021-12-26','YYYY-MM-dd') as Wrong2022
,date_format(date_add(current_date,51),'YYYY-MM-dd') as Correct2021b
,date_format(date_add(current_date,52),'YYYY-MM-dd') as Wrong2022b
我上面的代码返回
| correct2021 | wrong2022 | correct2021b | wrong2022b |
|---|---|---|---|
| 2021-12-25 | 2022-12-26 | 2021-12-25 | 2022-12-26 |
如果在 2021 年 11 月 4 日之后的其他日期运行,您需要调整添加的日期。
【问题讨论】:
标签: sql date hive hiveql simpledateformat