neha khemani
neha khemani

Reputation: 1

How to convert date in YYYYMMDD in Hive to unix timestamp

I am trying to convert date in format YYYYMMDD in hive to unix_timestamp but when I do below, I am getting incorrect timestamp.

select unix_timestamp(DATE,'YYYYMMDD') from table_name.

For '20180301' I am getting unix timestamp output as '1514631600' which is DECEMBER 30,2017 11:59 pm

Upvotes: 0

Views: 9121

Answers (1)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

The format string should be yyyyMMdd.

select unix_timestamp(DATE,'yyyyMMdd') from table_name

Upvotes: 1

Related Questions