Convert Interger or decimal to Date format
When you have interger or decimal value and you need to change in date format.
(1) Change integer or decimal value to string using CAST function.
(2) Convert into unix_timestamp with format e.g 'YYYYMMDD'
(3) Convert into from_unixtime()
(4) Convert into date_format() in required format e.g 'yyyy-MM-dd'
Example:
Date in decimal - birth_dt = 1956324.0
Solution:
SELECT date_format(from_unixtime(unix_timestamp(cast(birth_date as string),'YYYYMMDD')),'yyyy-MM-dd') as birth_dt from dummy
Result:
birth_dt = 1956-01-01