Created 10-10-2016 10:07 AM
My date looks like this:
2016-09-13T06:03:51Z |
I need to convert it in dd-mm-YYYY hh:mm:ss format. HOw do I do it?
I tried:
from_unixtime(unix_timestamp(created_at , 'dd-MM-yyyy HH-mm-ss'))
but it didnot work and gives null
Created 10-10-2016 08:05 PM
Hi @Simran Kaur,
You can still achieve this using out-of-the-box functions in Hive as you mentioned. You just missed getting the string in the right format. For clarity, the basic steps are:
Here is a quick example you can run in Hive to see the result for the string you provided:
select from_unixtime(unix_timestamp(regexp_replace('2016-09-13T06:03:51Z', 'T',' ')), 'dd-MM-yyyy HH-mm-ss');
Notice that the only additional step is the replace operation.
Created 10-10-2016 08:05 PM
Hi @Simran Kaur,
You can still achieve this using out-of-the-box functions in Hive as you mentioned. You just missed getting the string in the right format. For clarity, the basic steps are:
Here is a quick example you can run in Hive to see the result for the string you provided:
select from_unixtime(unix_timestamp(regexp_replace('2016-09-13T06:03:51Z', 'T',' ')), 'dd-MM-yyyy HH-mm-ss');
Notice that the only additional step is the replace operation.
Created 11-23-2017 05:46 AM
if I am using above function getting null . Please reply