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: 

How can I store timestamps using the local (not offset) timestamp instead of storing as UTC-Offset?

jonathan-dufaul
Valued Contributor

I have data that looks like this:

2021-11-25T19:00:00.000-0500
2021-03-03T13:00:00.000-0500
2021-03-09T15:00:00.000-0500
2021-03-13T16:00:00.000-0500
2021-03-19T03:00:00.000-0400
2021-05-28T03:00:00.000-0400

which is accurate, except I'm pulling the data to tableau server, and tableau displays all datetimes as UTC regardless of the local user's timezone. This reporting is leaving the local users confused, since the timestamps on the report do not match their timestamps for the process being reported (e.g. a user in Atlanta knows they started their process at 7:00AM, but the time in the tableau report is 12:00PM).

I want to be able to store the datetimes as the local time in databricks to work around this behavior, and have an additional column that stores the offset (like -5 for EST)

I have searched so much and have no idea if I'm just asking the wrong question or approaching the problem wrong. my end goal is displaying the correct date for every local user in tableau server. whatever the best practice is to accomplish this.

4 REPLIES 4

Anonymous
Not applicable

You have a couple options. There is a sql function to change the time zone.

You can also set the time zone on the cluster

I am familiar with those but I believe they only work to change the timezone for the entire session/cluster. I have multiple timezones in the dataset from different sites throughout the USA. I want a column to be "local time" and then another column to be "what timezone is the local time in"

For example:

local datetime                           timezone
2021-11-25T19:00:00.000        -0500
2021-03-03T13:00:00.000     -0500
2021-03-09T15:00:00.000     -0500
2021-03-13T16:00:00.000       -0500
2021-03-19T03:00:00.000      -0400
2021-05-28T03:00:00.000     -0400

or

local dateti                               timezone
2021-11-25T19:00:00.000       eastern
2021-03-03T13:00:00.000     eastern
2021-03-09T15:00:00.000     eastern
2021-03-13T16:00:00.000       eastern
2021-03-19T03:00:00.000      atlantic
2021-05-28T03:00:00.000     atlantic

Anonymous
Not applicable

Hi @Jonathan Dufault​ 

Hope everything is going great.

Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best so that other members can find the solution more quickly? If not, please tell us so we can help you. 

Cheers!

The question is not resolved and my most recent reply shows exactly what I want the output to be for a set of inputs. I don't know what else I can do to make it clearer.

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