Created
April 16, 2013 02:40
-
-
Save shermozle/5392938 to your computer and use it in GitHub Desktop.
Let the database do the work of timezone conversion. Mainly because Tableau isn't great at this. This is Postgres. Timezone names from http://en.wikipedia.org/wiki/Zone.tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"events"."collector_tstamp" AT TIME ZONE 'Australia/Sydney' AS "collector_tstamp AEST" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Simon,
Are you sure this works? I think it needs to be:
SET TIME ZONE 'Australia/Melbourne';
SELECT collector_tstamp AT TIME ZONE 'UTC'
FROM atomic.events
LIMIT 1;
When you use AT TIME ZONE, it set's the timezone of the data (there isn't a TZ attached to the Snowplow data). Then, whatever you have your timezone set to, SP will automatically show it in your local time.
I ran the following query to check the latest events in my Snowplow DB:
SELECT
MAX("collector_tstamp") AT TIME ZONE 'UTC' AS "collector_tstamp UTC",
MAX("collector_tstamp") AT TIME ZONE 'AEST' AS "collector_tstamp AEST"
FROM
"atomic".events;
Here's what it pulled for each column (note my Snowplow job runs each day at 12pm AEST):
2013-12-08 10:39:55+11 2013-12-08 00:39:55+11
As you can see, the first value is closest to the run date - which makes sense.