Thread

  1. Problems with default date 'now'

    Petter Reinholdtsen <pere@td.org.uit.no> — 1998-06-09T16:19:49Z

    I have a table where I want the default value of a date field to be
    todays date when I do insert.  I have this table definition:
    
    CREATE TABLE testdate(
    	received date DEFAULT 'now',
    	info text NOT NULL
    	);
    
    The problem is that the 'now' apparently is substituted when I create
    the table, not when I insert into it.  Is there another way to handle
    this?  This is on Linux RedHat 5.0 with PostgreSQL 6.2.1.
    
    Please remember to send replies to me (too), as I am not member on
    this mailing-list.
    
    Happy hacking,
    -- 
    ##>  Petter Reinholdtsen <##    | pere@td.org.uit.no
     O-  <SCRIPT Language="Javascript">window.close()</SCRIPT>
    http://www.hungry.com/~pere/    | Go Mozilla, go! Go!
    
    
    
  2. Re: [SQL] Problems with default date 'now'

    Jerome Alet <alet@unice.fr> — 1998-06-10T06:49:59Z

    Petter Reinholdtsen wrote:
    > 
    > I have a table where I want the default value of a date field to be
    > todays date when I do insert.  I have this table definition:
    > 
    > CREATE TABLE testdate(
    >         received date DEFAULT 'now',
    >         info text NOT NULL
    >         );
    > 
    > The problem is that the 'now' apparently is substituted when I create
    > the table, not when I insert into it.  Is there another way to handle
    > this?  This is on Linux RedHat 5.0 with PostgreSQL 6.2.1.
    > 
    
    replace your field definition with this one: 
    
    received_date DATE DEFAULT CURRENT_DATE
    
    it works fine.
    
    bye,
    
    Jerome ALET - alet@unice.fr - http://cortex.unice.fr/~jerome
    Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 
    28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
    
    
  3. Re: [SQL] Problems with default date 'now'

    jose' soares <sferac@bo.nettuno.it> — 1998-06-10T12:50:18Z

    On Tue, 9 Jun 1998, Petter Reinholdtsen wrote:
    
    > 
    > I have a table where I want the default value of a date field to be
    > todays date when I do insert.  I have this table definition:
    > 
    > CREATE TABLE testdate(
    > 	received date DEFAULT 'now',
    > 	info text NOT NULL
    > 	);
    > 
    
    CREATE TABLE testdate(
     	received date DEFAULT CURRENT_DATE,
     	info text NOT NULL
     	);
    
    > The problem is that the 'now' apparently is substituted when I create
    > the table, not when I insert into it.  Is there another way to handle
    > this?  This is on Linux RedHat 5.0 with PostgreSQL 6.2.1.
    > 
                        Jose'