0

I have a string containing date in it.

It looks like:

01JAN2020
02FEB2020

I use the following code to parse it to date format but didn't succeed:

a= a.withColumn('dt_one', to_date(unix_timestamp(col('dt_one'), 'dLy').cast("timestamp")))

Do you know the right syntax to do this?

Thanks!

Yi Du
  • 455
  • 2
  • 8
  • 17

1 Answers1

0

I think this should work:

a= a.withColumn('dt_one', to_date(unix_timestamp(col('dt_one'), 'dMMMy').cast("timestamp")))
Yi Du
  • 455
  • 2
  • 8
  • 17