Search code examples
stringdatecastinghive

Hive cast string to date dd-MM-yyyy


How can I cast a string in the format 'dd-MM-yyyy' to a date type also in the format 'dd-MM-yyyy' in Hive?

Something along the lines of:

CAST('12-03-2010' as date 'dd-mm-yyyy')

Solution

  • try:

    from_unixtime(unix_timestamp('12-03-2010' , 'dd-MM-yyyy'))