Hive’s unix_timestamp and from_unixtime functions

From the language manual:

Convert time string with given pattern to Unix time stamp (in seconds) The result of this function is in seconds.

Your result changes with the milliseconds portion of the date, but the unix functions only support seconds. For example:

SELECT unix_timestamp('10-Jun-15 10.00.00 AM', 'dd-MMM-yy hh.mm.ss a');

1433930400

SELECT from_unixtime(1433930400, 'dd-MMM-yy hh.mm.ss a');

10-Jun-15 10.00.00 AM

Leave a Comment