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:ย 

Date formatting

Nathant93
New Contributor III

Does anyone know how to change the format of a date like this 

Dec 17 2016 8:22PM

into yyyy-MM-dd hh:mm:ss?

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Krishnamatta
New Contributor III

 

Convert to timestamp first and then format to string

select  date_format(to_timestamp('Dec 17 2016 8:22PM', 'MMM dd yyyy h:ma'), "yyyy-MM-dd HH:mm:ss")

Here is the documentation for this:

https://docs.databricks.com/en/sql/language-manual/sql-ref-datetime-pattern.html

View solution in original post

1 REPLY 1

Krishnamatta
New Contributor III

 

Convert to timestamp first and then format to string

select  date_format(to_timestamp('Dec 17 2016 8:22PM', 'MMM dd yyyy h:ma'), "yyyy-MM-dd HH:mm:ss")

Here is the documentation for this:

https://docs.databricks.com/en/sql/language-manual/sql-ref-datetime-pattern.html

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