Re: [INTERFACES] where did that date and time come from??

From: Chairudin Sentosa <chairudin(at)prima(dot)net(dot)id>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>, "'pgsql-admin(at)hub(dot)org'" <pgsql-admin(at)hub(dot)org>, "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>
Subject: Re: [INTERFACES] where did that date and time come from??
Date: 1999-04-23 09:13:12
Message-ID: 372039A8.51FDEA58@prima.net.id
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces pgsql-sql

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martin Weinberg 1999-04-23 13:41:45 Problem with an indexing on a large table. Suggestions needed.
Previous Message Richard Lynch 1999-04-23 06:49:49 Trigonometry

Browse pgsql-interfaces by date

  From Date Subject
Next Message Burg, Edmund von der 1999-04-23 11:24:34 unsubscribe
Previous Message Pavel PaJaSoft Janousek 1999-04-23 08:17:03 Re: [INTERFACES] ecpg cursors and scope

Browse pgsql-sql by date

  From Date Subject
Next Message Julian Scarfe 1999-04-23 10:30:14 Re: [SQL] Finding the "most recent" rows
Previous Message Chairudin Sentosa 1999-04-23 08:36:15 Re: [SQL] SELECT TOP _x_ ??