pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chairudin Sentosa <chairudin@prima.net.id>
To: Thomas Lockhart <lockhart@alumni.caltech.edu>
Cc: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-admin@hub.org' <pgsql-admin@hub.org>
Cc: 'pgsql-interfaces@hub.org' <pgsql-interfaces@hub.org>
Subject: Re: [INTERFACES] where did that date and time come from??
Date: Fri, 23 Apr 1999 02:13:12 -0700
Message-ID: <372039A8.51FDEA58@prima.net.id> (raw)
References: <01BE8A7D.00789480.jt-kirkpatrick@mpsllc.com>
	<371C91C5.2A7E4B4B@alumni.caltech.edu>

Thomas Lockhart wrote:

> > I have a database that has four fields -
> > Create table dispnote (
> > Autoinv int4
> > noteby char(8) not null default 'current_user',
> > added datetime not null default 'now',
> > notes varchar(255),
> > constraint dispnotepk primary key (autoinv, added),
> > constraint dispnotessms foreign key (auoinv) references ssms
> > );
> > ... But when I insert a record it came up with a date of april 14, 10am!  My
> > server and my client both have the correct date and time (april 19, 3pm) -
> > where did it get the wrong date and time from??
>
> This is (still) a problem with Postgres optimizing untyped constants
> by evaluating them at table creation time rather than at run time.
> Redefine your datetime field as
>
>   ...
>   added datetime not null default text 'now',
>   ...
>
> to force the type of the default value to be a string, which is then
> converted at run time as you would expect. Fixing this behavior would
> seem to be a good project for someone (maybe me :) for v6.6...
>

How about this?
added datetime default datetime(now()) not null,

Is this one OK?

Regards,
Chai




view thread (4+ messages)

Message-ID: <372039A8.51FDEA58@prima.net.id>
Permalink:  ../372039A8.51FDEA58@prima.net.id/
Also on:    postgresql.org/message-id/372039A8.51FDEA58@prima.net.id

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: chairudin@prima.net.id, lockhart@alumni.caltech.edu, jt-kirkpatrick@mpsllc.com, pgsql-admin@hub.org, pgsql-interfaces@hub.org
  Subject: Re: [INTERFACES] where did that date and time come from??
  In-Reply-To: <372039A8.51FDEA58@prima.net.id>

* 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