我有一个小问题,我想用 hive 查询过滤日期,但输出为空。我的专栏是字符串类型
我试过这个:
select * from my_table
where to_date(date) < to_date('01/08/19 00:00:00')
我的专栏日期的格式是01/08/19 18:00:00
我有一个小问题,我想用 hive 查询过滤日期,但输出为空。我的专栏是字符串类型
我试过这个:
select * from my_table
where to_date(date) < to_date('01/08/19 00:00:00')
我的专栏日期的格式是01/08/19 18:00:00
这种格式'01/08/19 00:00:00'
的日期不是可比较的格式,因为这种格式'02/08/19 00:00:00'
大于'01/08/20 00:00:00'
.
使用unix_timestamp
andfrom_unixtime
转换为可比较的格式 ( 'yyyy-MM-dd HH:mm:ss'
),然后与相同格式的日期进行比较。
select * from my_table
where from_unixtime(unix_timestamp(date,'dd/MM/yy HH:mm:ss'),'yyyy-MM-dd HH:mm:ss') < '2019-08-01 00:00:00'