From: | "Hutton, Rob" <HuttonR(at)plymart(dot)com> |
---|---|
To: | "Hutton, Rob" <HuttonR(at)plymart(dot)com>, "'Patrik Kudo'" <kudo(at)partitur(dot)se> |
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:36:56 |
Message-ID: | 11EFC736FB68D111B9DD00805FAD7C6D1E0C37@plymartpdc.internal.plymart.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
sorry, Here's the create statement.
CREATE TABLE "orders" (
"ord_id" int4 DEFAULT nextval ( 'next_ord_id' ) NOT NULL,
"req_id" int4 DEFAULT nextval ( 'next_req_id' ) NOT NULL,
"ord_description" character varying(1500),
"ord_priority" character varying(1500),
"ord_pri_order" int4,
"ord_time" time DEFAULT now(),
"ord_date" date DEFAULT now(),
"ord_timestamp" datetime DEFAULT now(),
"ord_tech" character varying(1500),
"ord_stat" character varying(2),
"ord_notes" character varying(1500),
"ord_whse" int4);
-----Original Message-----
From: Hutton, Rob
Sent: Friday, August 13, 1999 10:25 AM
To: 'Patrik Kudo'; Hutton, Rob
Cc: 'pgsql-sql(at)postgresql(dot)org'
Subject: RE: [SQL] Problems with default date and time
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
From | Date | Subject | |
---|---|---|---|
Next Message | Patrik Kudo | 1999-08-13 14:57:22 | Re: [SQL] Problems with default date and time |
Previous Message | Tom Lane | 1999-08-13 14:27:15 | Re: [SQL] Searching Text Fields - Case Sensitive? |