Home > Blockchain >  Convert string to datetime format in databricks using sql
Convert string to datetime format in databricks using sql

Time:03-02

I am facing error while converting the string to datetime format in databricks :

select to_date('01Jan1971:00:00:00','DDMONYYYY:HH:MI:SS')

Error in SQL statement: IllegalArgumentException: All week-based patterns are unsupported since Spark 3.0, detected: Y, Please use the SQL function EXTRACT instead

com.databricks.backend.common.rpc.DatabricksExceptions$SQLExecutionException: java.lang.IllegalArgumentException: All week-based patterns are unsupported since Spark 3.0, detected: Y, Please use the SQL function EXTRACT instead at org.apache.spark.sql.catalyst.util.DateTimeFormatterHelper$.$anonfun$convertIncompatiblePattern$4(DateTimeFormatterHelper.scala:323) at org.apache.spark.sql.catalyst.util.DateTimeFormatterHelper$.$anonfun$convertIncompatiblePattern$4$adapted(DateTimeFormatterHelper.scala:321)

CodePudding user response:

This command worked

select to_date(upper('01Jan1971:00:00:00'),'ddMMMyyyy:HH:mm:ss')

  • Related