【发布时间】:2022-01-25 04:03:37
【问题描述】:
我需要在以特定日期为中心的日期范围之间进行选择,但我的日期分区列存储为 int。
例如,在“20210901”之前和之后的日期之间进行选择(20210831 到 20210902)
有没有比我在下面想出的方法更简单的方法?
between cast(date_format(date_sub(date_format(from_unixtime(unix_timestamp(cast('20210901' as string),'yyyyMMdd')),'yyyy-MM-dd'),1),'yyyyMMdd') as int) and \
cast(date_format(date_add(date_format(from_unixtime(unix_timestamp(cast('20210901' as string),'yyyyMMdd')),'yyyy-MM-dd'),1),'yyyyMMdd');
【问题讨论】:
标签: sql date hive casting timestamp