timma
timma

Reputation: 243

How to convert this time to hive timestamp

I have a timestamp value as below:

20171020T222028.026 GMT 

I want to convert this to the following format:

2018-12-01 19:35:05 

Is this possible in Hive ? Input - 20171020T222028.026 GMT

Output - 2017-10-20 22:20:28

Upvotes: 1

Views: 238

Answers (1)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49270

The input format needs to be parsed as shown here. No format parameter is needed for from_unixtime as the expected output is in the default output format yyyy-MM-dd HH:mm:ss

select from_unixtime(unix_timestamp('20171020T222028.026 GMT',"yyyyMMdd'T'HHmmss.SSS z"))

Formats:

  • 'T' to escape the literal in the input value.
  • z for Timezone

Upvotes: 2

Related Questions