Convert date format.

I have date format in m/dd/yyyy h:mm and mm/dd/yyyy h:mm and I want output in yyyy-mm-dd hh:mm:ss in spark-sql. But i am getting null.
I have values like 8/6/2018 0:00 and 12/28/2018 0:00 and I want it in yyyy-mm-dd hh:mm:ss format .
I am using…....
mystuff.withColumn('date_col',unix_timestamp("date_col","MM/dd/yyyy h:mm ")
mystuff is table name and date_col is the column name that I want to convert to .
But I am getting answer as null. Anyone have an idea to do this?
Thanks in advance.

Tagged:
Sign In or Register to comment.