cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

one of the date datatype format issue in pysaprk

KVNARK
Honored Contributor II

if anyone has encountered this date type format - 6/15/25 12:00 AM could you mention the right formatting to be used in Pyspark.

Thanks in advance!

3 REPLIES 3

UmaMahesh1
Honored Contributor III

Hi @KVNARK .โ€‹ 

You can use the below formatting to get it into a timestamp format...

to_timestamp('6/15/25 12:00 AM', 'MM/dd/yy hh:mm aa')

This will give you the timestamp like this -- 2025-06-15T00:00:00.000+0000

If you want only the date part, you can use to_date function.

Hope this helps...Cheers..

Uma Mahesh D

UmaMahesh1
Honored Contributor III

FYI... You also have to set set spark.sql.legacy.timeParserPolicy = LEGACY for the above to work..

Uma Mahesh D

Hubert-Dudek
Esteemed Contributor III

Without legacy, it will also work.image.png

SELECT to_timestamp('6/15/23 12:00 AM', 'M/dd/yy h:mm a')

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group