Search code examples
hivehiveql

Why select unix_timestamp('2022-07-29') returns null in hive?


Select unix_timestamp(CURRENT_DATE) returns proper value but select unix_timestamp('2022-07-29') returns null in hive.Any idea how to get proper values by using unix_timestamp('2022-07-29') in hive?


Solution

  • Please use string format along with the function. Use

    select unix_timestamp('2022-07-29','yyyy-MM-dd')
    

    current_date works because internally hive converts it to a string format that hive recognizes and it is able to convert it to a unix timestamp integer.