Hive cast string to date dd-MM-yyyy

pele88 picture pele88 · Sep 9, 2015 · Viewed 163.4k times · Source

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')

Answer

Ardit picture Ardit · Sep 9, 2015

try:

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