I have a date field in the format of yyyy-MM-dd-hh.mm.ss coming from a db2 source.I want to load into hive and convert to timestamp.
How do I achieve it ?
You can use a combination of unix_timestamp
and from_unixtime
instead of the substr
method that you are currently using.
select cast(
from_unixtime(
unix_timestamp('2017-08-31-12:24:48' , 'yyyy-MM-dd-HH:mm:ss')
)
as timestamp
);
+------------------------+--+
| _c0 |
+------------------------+--+
| 2017-08-31 12:24:48.0 |
+------------------------+--+