Strange behavior with timestamptz

From: "George Weaver" <georgew1(at)mts(dot)net>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Strange behavior with timestamptz
Date: 2003-08-25 18:18:03
Message-ID: 006801c36b35$524ecac0$4f0da18e@cleartag
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Everyone,

I have a situation where two tables have a "Created" field defined as follows:

table seedlot "created timestamptz DEFAULT now(), "

table transaction "created timestamptz NOT NULL DEFAULT now(),"

The transaction table records when a seedlot record is created, with both events happening in the same plpgsql function. The seedlot record is created first, with the transaction table being updated later in the procedure.

Seedlot 153 was received on August 11 with the following result:

base=# select created from seedlot where syslotid=153;
created
------------------------
2003-11-08 12:13:39-06
(1 row)

base=# select created from transaction where syslotid=153 and transactiontypeid=22;
created
------------------------
2003-08-11 12:13:39-05
(1 row)

Does anyone have any idea why the default for seedlot recorded the time with the day and month switched, resulting in the seedlot record being stamped Nov 8, 2003 while the transaction was stamped correctly as Aug 11, 2003?

In the same function a number of other records are created and timestamped. In all cases where the table definition statement does not include NOT NULL, the time was stamped with the day and month reversed.

However! Two of the tables define created thus:

"created timestamptz DEFAULT now() NOT NULL,"

but still ended up with the day and month being switched.

The transaction record is the last one in the procedure to be created.

I am using version 7.3.2.

I hope I'm not missing something obvious...

Thanks for your help,
George

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-08-25 20:59:39 Re: Strange behavior with timestamptz
Previous Message Michele Bendazzoli 2003-08-25 07:16:52 Re: [ZODB-Dev] What are the ZopeDB limit?