Petros Tsialiamanis
Petros Tsialiamanis

Reputation: 2758

Convert string into timestamp in Hive

I have a value '2017-09-27T19:25:15.927-07:00', is there any way to convert this into a timestamp? I use Hive 1.1.0.

select unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-ddTHH:mm:ss.SSSX") but it trows Bad date/time conversion format

select unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-ddTHH:mm:ss.SSSZZZ") but it returns NULL

Upvotes: 2

Views: 12474

Answers (1)

nobody
nobody

Reputation: 11080

The format is yyyy-MM-dd'T'HH:mm:ss.SSSXXX".Note the single quotes surrounding 'T'

select from_unixtime(unix_timestamp("2017-09-27T19:25:15.927-07:00", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"))

Upvotes: 7

Related Questions