Reputation: 11
Environment: Hive query
How can I convert yyyyddd (ddd=day of the year) with hive query into yyyy-mm-dd ?
Regards,
Upvotes: 0
Views: 1042
Reputation: 591
you can convert it like below
hive> select from_unixtime(unix_timestamp('2017032','yyyyddd'),'yyyy-MM-dd');
OK
2017-02-01
Upvotes: 2
Reputation: 1269873
You should be able to do this with string manipulation functions. I don't have Hive on hand, but something like this:
date_add(concat(substr(yyyyddd, 1, 4), '-01-01'),
cast(substr(yyyyddd, 5, 3) as int) - 1
)
Upvotes: 0