当日期是时间戳时在指定日期之间过滤数据

时间:2021-03-15 16:14:27

标签: hadoop hive dbd-pg

我正在尝试在 Hive 表中过滤 2021 年 1 月 1 日和 2021 年 1 月 31 日之间的数据。包含日期的列采用时间戳格式 (yyyy-mm-dd hh-mm-ss)。有没有办法只根据 year() 月份和日期进行过滤而不输入时间?欢迎任何示例/示例代码!

1 个答案:

答案 0 :(得分:0)

您可以使用 to_date( dt_time timestamp) dt 转换为日期并删除时间部分。

select current_timestamp() , to_date(current_timestamp() )

enter image description here

Select * from table 
Where
To_date(input_datetime ) between to_date(from_datetime) and to_date (to_datetime)
相关问题