Received: from bastuba.partitur.se (bastuba.partitur.se [193.219.246.194]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA72542 for ; Fri, 13 Aug 1999 10:05:20 -0400 (EDT) (envelope-from kudo@partitur.se) Received: from partitur.se (tb303.partitur.se [193.219.246.230]) by bastuba.partitur.se (8.8.8/8.8.8) with ESMTP id QAA15215; Fri, 13 Aug 1999 16:04:36 +0200 (CEST) (envelope-from kudo@partitur.se) Sender: kudo@partitur.se Message-ID: <37B425F4.DF2F4037@partitur.se> Date: Fri, 13 Aug 1999 16:04:36 +0200 From: Patrik Kudo Organization: Partitur Informationsteknik X-Mailer: Mozilla 4.61 [en] (X11; I; FreeBSD 3.2-STABLE i386) X-Accept-Language: sv,en MIME-Version: 1.0 To: "Hutton, Rob" CC: "'pgsql-sql@postgresql.org'" Subject: Re: [SQL] Problems with default date and time References: <11EFC736FB68D111B9DD00805FAD7C6D1E0C35@plymartpdc.internal.plymart.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > "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". Also, I'd skip the time and date fields and exchange timestamp with datetime. You would still be able to get the date and time from the ord_timestamp field using: select ord_timestamp::time, ord_timestamp::date from tablename; The reason I'd use datetime instead of datetime is because you can't cast from timestamp to time (afaik). Hope this helps. /Kudo