From: | "Hutton, Rob" <HuttonR(at)plymart(dot)com> |
---|---|
To: | "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Patrik Kudo <kudo(at)partitur(dot)se> |
Cc: | "Hutton, Rob" <HuttonR(at)plymart(dot)com>, "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | RE: [SQL] Problems with default date and time |
Date: | 1999-08-13 16:40:22 |
Message-ID: | 11EFC736FB68D111B9DD00805FAD7C6D1E0C39@plymartpdc.internal.plymart.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
The problem is that I'm doing some reporting from crystal reports using the
ODBC driver, and I need to offer a range to limit the dates that are
printed. Will this work with a datetime column?
ex.
Select * from table1 where datetimecolumn between 01/01/1999 and 01/15/1999
Rob
-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Friday, August 13, 1999 11:02 AM
To: Patrik Kudo
Cc: Hutton, Rob; 'pgsql-sql(at)postgresql(dot)org'
Subject: Re: [SQL] Problems with default date and time
Patrik Kudo <kudo(at)partitur(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Chad Miller | 1999-08-14 00:13:00 | err: select f() from i where (f()) in (select f() from x group by j); |
Previous Message | Mike Field | 1999-08-13 15:11:00 | Multiple values for a field |