Date format issue with spark sql

 If you have date format like 


date_col

1/1/1978 0:00

6/6/1975 0:00

1/1/1978 0:00

1/1/1978 0:00

7/23/1988 0:00

1/1/1978 0:00

1/26/1961 0:00

3/3/1980 0:00

6/2/1984 0:00

1/2/1971 0:00



Solution :

substring(TO_DATE(date_col ,'MM/dd/yy'),0,10) from table

Result :


1978-01-01
1975-06-06
..
1988-07-23
..



Comments

Popular posts from this blog

Hive Partition sub folders HIVE_UNION_SUBDIR_1,HIVE_UNION_SUBDIR_2,HIVE_UNION_SUBDIR_8

Dataiku and Dremio date difference