From: | Patrik Kudo <kudo(at)partitur(dot)se> |
---|---|
To: | "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:04:36 |
Message-ID: | 37B425F4.DF2F4037@partitur.se |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> "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 | Hutton, Rob | 1999-08-13 14:25:29 | RE: [SQL] Problems with default date and time |
Previous Message | Hutton, Rob | 1999-08-13 13:44:18 | Problems with default date and time |