Reputation: 99
How to return month from varchar
column and values like "20180912" in hive?
It's strange that it worked fine with function month()
on string type in hive,however it returns null now.
And month(from_unixtime(unix_timestamp)(date,'yyyymmdd'))
return vaules that do not match the real month
Upvotes: 1
Views: 25
Reputation: 38325
Use substr()
:
hive> select substr('20180912',5,2);
OK
09
Time taken: 1.675 seconds, Fetched: 1 row(s)
Upvotes: 1