On 10/02/2013 01:49 AM, Tim Uckun
wrote:
As I mentioned in a separate reply, the best mental-model I've found for the ill-named "timestamp with time zone" is "point in time." If you also need the location (or just the time zone) of an event I would recommend using two fields one of which is the event_timestamp as a timestamp with time zone (point in time) and the other is the event_timezone which is a text column with the full timezone name. You can get a full list of recognized time-zone names with "select * from pg_timezone_names". I recommend storing the data as a timestamp with time zone and a full time-zone name to avoid data ambiguity during daylight saving changes. I.e. when the clock falls-back you will have 1:30 am twice if you are storing a timestamp without time zone. This *may* be disambiguated if you use an appropriate zone abbreviation like 1:30 EST vs 1:30 EDT but abbreviations lead to other problems in worldwide data including the problem that abbreviations may be reused leading to weirdness like needing to set the AUSTRALIAN_TIMEZONES parameter properly to avoid conflict with EST (Australian Eastern Standard Time) and EST (US Eastern Standard Time) among others - this will be even more "fun" if trying to select from a table that includes both Australian and United States data. If you structure the data as recommended above you can simply get the local time as: SELECT ..., event_timestamp at time zone event_timezone as event_local_time, ... when you need the local time but you will still retain the exact point-in-time for use as needed. Cheers, Steve |