Skip site navigation (1) Skip section navigation (2)

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

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>
Cc: "'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-20 14:40:05
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-interfacespgsql-sql
> 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...

                        - Tom

Thomas Lockhart				lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to


pgsql-sql by date

Next:From: Dirk LutzebaeckDate: 1999-04-20 15:11:42
Subject: SELECT LIMIT not working with unions?
Previous:From: Tom LaneDate: 1999-04-20 14:35:30
Subject: Re: [SQL] Questions about embedded-sql!

pgsql-interfaces by date

Next:From: Peter MountDate: 1999-04-20 15:05:49
Subject: RE: [INTERFACES] Compiling jdbc for Linux and Solaris
Previous:From: Kent PerrierDate: 1999-04-20 14:38:18
Subject: Re: [INTERFACES] Compiling jdbc for Linux and Solaris

pgsql-general by date

Next:From: Michael J DavisDate: 1999-04-20 16:08:43
Subject: RE: [GENERAL] How to get seq after insert
Previous:From: Karl DeBisschopDate: 1999-04-20 13:17:42
Subject: Re: [GENERAL] problem when vacuuming. . .

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group