datedatabricksdate-conversiondatabricks-sqlstring-to-datetime

How to convert YYYYMMDD string to date in databricks SQL end point?


How to convert YYYYMMDD string to date in databricks SQL end point?

Input values:- 1. 20230804

           2. 20230805

output values :- 1. 2023-08-04

             2. 2023-08-05

Solution

  • SELECT
      TO_DATE(your_column_name, 'yyyyMMdd') as formatted_date
    FROM
      your_table_name;