pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrik Kudo <kudo@partitur.se>
To: Hutton, Rob <HuttonR@plymart.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] Problems with default date and time
Date: Fri, 13 Aug 1999 16:04:36 +0200
Message-ID: <37B425F4.DF2F4037@partitur.se> (raw)
References: <11EFC736FB68D111B9DD00805FAD7C6D1E0C35@plymartpdc.internal.plymart.com>

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



view thread (7+ messages)  latest in thread

Message-ID: <37B425F4.DF2F4037@partitur.se>
Permalink:  ../37B425F4.DF2F4037@partitur.se/
Also on:    postgresql.org/message-id/37B425F4.DF2F4037@partitur.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: kudo@partitur.se, HuttonR@plymart.com
  Subject: Re: [SQL] Problems with default date and time
  In-Reply-To: <37B425F4.DF2F4037@partitur.se>
  References: <11EFC736FB68D111B9DD00805FAD7C6D1E0C35@plymartpdc.internal.plymart.com> <37B425F4.DF2F4037@partitur.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox