From: Tom Lane <tgl@sss.pgh.pa.us>
To: Patrik Kudo <kudo@partitur.se>
Cc: Hutton, Rob <HuttonR@plymart.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Problems with default date and time
Date: Fri, 13 Aug 1999 11:02:25 -0400
Message-ID: <4539.934556545@sss.pgh.pa.us> (raw)
In-Reply-To: <37B425F4.DF2F4037@partitur.se>
Patrik Kudo <kudo@partitur.se> writes:
>> "Hutton, Rob" wrote:
>>
>> I have created a table with date and time fields by using what I
>> read as being the correct default statements, but I get the date and
>> time the DB was created at each insert instead of the current date and
>> time.
>> | ord_time | time default text 'now'
>> | 8 |
>> | ord_date | date default text 'now'
>> | 4 |
>> | ord_timestamp | timestamp default text 'now'
>> | 4 |
> You should not use 'now'. It will be replaced with the current time.
> Instead use now() and remove "text".
The "default text 'now'" hack doesn't work with TIMESTAMP columns, only
with DATETIME columns --- this was reported last month. I forget the
details but I think it is triggered by the presence of slightly
different sets of datatype conversion routines for the two types in the
system tables, leading to a different path being taken that evaluates
the default clause's value when it should not. Probably a default of
"now()" would fail for the same reason. Fixing this is on the TODO
list, but I do not think it is a trivial fix.
In the meantime, I suggest using a DATETIME column --- or two of them,
if you need the ability to record two different dates/times.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, kudo@partitur.se, HuttonR@plymart.com
Subject: Re: [SQL] Problems with default date and time
In-Reply-To: <4539.934556545@sss.pgh.pa.us>
References: <37B425F4.DF2F4037@partitur.se> <4539.934556545@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox