Reputation: 8635
in hive sql I have the following field as date time
date_time
2017-01-01 12:00:00
min_date
2017-02-01 12:00:00
can I compare both fields as date_time > min_date
in my sql query?
how do we compare date time in hive sql?
both timestamp types
Upvotes: 2
Views: 3113
Reputation: 38290
You can compare timestamps or strings if they are in sort-able format like this yyyy-MM-dd HH:mm:ss[.f...]
Demo:
hive> select cast('2017-01-01 12:00:00' as timestamp)>cast('2017-02-01 12:00:00' as timestamp);
OK
false
Time taken: 0.13 seconds, Fetched: 1 row(s)
Example with strings:
hive> select '2017-01-01 12:00:00'>'2017-02-01 12:00:00';
OK
false
Time taken: 1.053 seconds, Fetched: 1 row(s)
Upvotes: 1