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: 

Conversion of time zone from UTC to US/Eastern

Majid
New Contributor

Hi All,

I am new to databricks and i am writing a query to fetch the data from Databricks and encountered with an error. Please see below the query details and the error. Any help would be appreciated. 

Thank You in Advance ! 

Query: 

cast(TO_UTC_TIMESTAMP_TZ(Cast(substr(START_DATE_TIME,1,22), 'UTC')) AT TIME ZONE 'US/Eastern' as DATE) as START_DT_ET (This line of code is at Line 17 and the error is referring to this particular Line's code.)
 
Error: 

[PARSE_SYNTAX_ERROR] Syntax error at or near 'AT'. SQLSTATE: 42601 line 17, pos 111

, cast(TO_UTC_TIMESTAMP_TZ(Cast(substr(CREATION_DATE_TIME,1,22), 'UTC')) AT TIME ZONE 'US/Eastern' as DATE) as START_DT_ET

1 REPLY 1

szymon_dybczak
Contributor III

Hi @Majid ,

Spark SQL doesn't support  AT TIME ZONE, that's why you've got this error. To achieve similar result, you can use to_utc_timestamp or from_utc_timestamp function. Those functions support timezone parameter:

https://docs.databricks.com/en/sql/language-manual/functions/to_utc_timestamp.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