Reputation: 1037
I am running hive query to convert string to timestamp format:
References from:
Query:
select `timestamp`, unix_timestamp(`timestamp`,"yyyy-MM-dd'T'hh:mm:ss'X'")
from tbl1
where eventdate="2019-03-31"
limit 2;
Result:
2019-03-31T15:29:42.443-07:00 NULL
2019-03-31T13:35:10.929-07:00 NULL
I tried:
unix_timestamp(`timestamp`,"yyyy-MM-dd'T'hh:mm:ssX")
unix_timestamp(`timestamp`,"yyyy-MM-dd'T'hh:mm:ss:SSSX")
unix_timestamp(`timestamp`,"yyyy-MM-dd'T'hh:mm:ss:SSSZZZZ")
unix_timestamp(`timestamp`,"yyyy-MM-dd'T'hh:mm:ss:SSSZZ:ZZ")
I am getting NULL but not the timestamp converted.
Thanks.
Upvotes: 0
Views: 144
Reputation: 38290
Correct format is
"yyyy-MM-dd'T'HH:mm:ss.SSSX"
HH
, not hh
. See SimpleDateFormat for referenceUpvotes: 2