Re: When it is better to use "timestamp without time zone"?

From: Emi Lu <emilu(at)cs(dot)concordia(dot)ca>
To: andrew(at)supernews(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: When it is better to use "timestamp without time zone"?
Date: 2006-01-04 15:07:54
Message-ID: 43BBE4CA.6090804@cs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>In postgreSQL, the default value for timestamp is "without time zone".
>>
>>
>
>That's true only because the SQL standard says so, not because it's actually
>a good idea to use timestamps without time zone.
>
>
>>Can I say when data is used among diff time zones, timestamp with time
>>zone is a MUST; otherwise, timestamp without time zone is used?
>>
>>
>
>No. You should, IMO, use timestamp with time zone in essentially all cases.
>(In particular, you should _always_ use it for recording the time at which
>an event happened, which covers most uses of timestamps.) Only use timestamp
>without time zone for data storage if you have a specific reason to do so.
>
>
OK. When the column is setup as "timestamp with time zone default
now()", the default values will be set based on the Operating System,
right?

An example case:
PostgreSQL server is on machine1, with timezone setup as "-5". A table
named test1(col timestamp with time zone default now() );

. insert into test1 from client machine2 with timezone "+2"; the value
inserted into machine1 should be "2006-01-04 10:01:01-05" but not
"2006-01-04 10:01:01+02" ?

. select * from test1 from client machine2, we will get "2006-01-04
10:01:01-05" since the absolute value is saved, which is never caculated
again?

. What is the problem here when the column type is setup as "timestamp
without time zone"?
The value "2006-01-04 10:01:01" is saved and read from both machine1
and machine2.

Emi

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2006-01-04 15:32:05 problem with partitioning and indexed order by
Previous Message Andrew - Supernews 2006-01-04 14:41:24 Re: When it is better to use "timestamp without time zone"?