convert sting to Date data type in spark sql

AzeemK 516 Reputation points
2021-08-11T05:31:19.943+00:00

Whats the best way to convert this string in Date data type in spark sql

20210810 to 08/10/2021

I am keep getting null with T0_Date Function

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,514 questions
{count} votes

Accepted answer
  1. Martin Cairney 2,261 Reputation points
    2021-08-13T12:22:51.637+00:00

    To convert the string "20210810" to a date data type include the date format of the string in the to_date function, e.g:

    to_date(col("date"),"yyyyMMdd")
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.