Re: to_timestamp alternatives

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: gkhan <drjohnpayne(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: to_timestamp alternatives
Date: 2015-12-31 23:46:55
Message-ID: 5685BE6F.9050504@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/31/15 5:05 PM, gkhan wrote:
> For
> example, this fails because of the day-before-month format:

Right, which is why Tom had in his example:

regression=# set datestyle = dmy;

BTW, my recommendation would be to store in a timestamptz field *with
the correct timezone*, and then convert on output as necessary. This is
easy to do by either

SET timezone

or

SELECT timestamptz_field AT TIME ZONE '...';

If you want the time without DST, you can just use a timezone like '+8'
or '-8'.

Since you're dealing with GPS data and presumably have lat/long, it
shouldn't be hard to do this dynamically either, either by just blindly
dividing longitude by 15 or using actual timezone shape polygons and @>
or <@.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-01-01 00:16:07 Re: to_timestamp alternatives
Previous Message gkhan 2015-12-31 23:05:34 Re: to_timestamp alternatives