标签: hadoop hive dbd-pg
我正在尝试在 Hive 表中过滤 2021 年 1 月 1 日和 2021 年 1 月 31 日之间的数据。包含日期的列采用时间戳格式 (yyyy-mm-dd hh-mm-ss)。有没有办法只根据 year() 月份和日期进行过滤而不输入时间?欢迎任何示例/示例代码!
答案 0 :(得分:0)
您可以使用 to_date( dt_time timestamp) dt 转换为日期并删除时间部分。
to_date( dt_time timestamp) dt
select current_timestamp() , to_date(current_timestamp() )
Select * from table Where To_date(input_datetime ) between to_date(from_datetime) and to_date (to_datetime)