@sri vs​ if the hours are 0-23 then you'll have to use HH instead of hh:

https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-datetime-pattern.html#pat...

spark.sql("select date_format(to_timestamp(concat('20221009','010911'),'yyyyMMddHHmmss'),'yyyy-MM-dd hh:mm:ss a') as my_date").display()

View solution in original post