RE: [SQL] Problems with default date and time

From: "Hutton, Rob" <HuttonR(at)plymart(dot)com>
To: "'Patrik Kudo'" <kudo(at)partitur(dot)se>, "Hutton, Rob" <HuttonR(at)plymart(dot)com>
Cc: "'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 14:25:29
Message-ID: 11EFC736FB68D111B9DD00805FAD7C6D1E0C36@plymartpdc.internal.plymart.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The time and date fields are for reporting purposes while the timestamp is
for calculating elapsed time, so I need all of them. When I make those
changes, I get:

ERROR: DEFAULT clause type 'timestamp' mismatched with column type 'time'

-----Original Message-----
From: Patrik Kudo [mailto:kudo(at)partitur(dot)se]
Sent: Friday, August 13, 1999 10:05 AM
To: Hutton, Rob
Cc: 'pgsql-sql(at)postgresql(dot)org'
Subject: Re: [SQL] Problems with default date and time

> "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

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-08-13 14:27:15 Re: [SQL] Searching Text Fields - Case Sensitive?
Previous Message Patrik Kudo 1999-08-13 14:04:36 Re: [SQL] Problems with default date and time