Re: [GENERAL] Date & Time - Mailing list pgsql-general

From
Subject Re: [GENERAL] Date & Time
Date
Msg-id Pine.LNX.4.10.9912021352190.25587-100000@picasso.realtyideas.com
Whole thread Raw
List pgsql-general
I rechecked the results I sent before, it is not clear, becuase I
run it as a batch. I need a sleep :-) but I do not if there is
a sleep in sql or psql command. so, I use the vaccum! (this is
a development machine!). I re-run it, it looks good now!

anybody know any sleep-like thing for sql ?
##############################################################
test3=> drop table account;

DROP
test3=> CREATE TABLE account (

        test3->                  act char(1) default 'Y',

        test3->                  createdfunc DATETIME DEFAULT now(),

        test3->                  createdcons DATETIME DEFAULT 'now',

        test3->                  created2cons DATETIME DEFAULT 'current_timestamp',

        test3->                  createdcurr DATETIME DEFAULT 'current'

        test3->                  );

CREATE
test3=>

test3=>

test3=> insert into account values('y');

INSERT 283378 1
test3=> vacuum;
VACUUM
test3=> insert into account values('1');

INSERT 283379 1
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values(now());

INSERT 283380 1
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values(now);

ERROR:  Attribute now not found
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values('now');

INSERT 283381 1
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values(current);
ERROR:  Attribute current not found
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values('current');

INSERT 283382 1
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values(current_timestamp);

INSERT 283383 1
test3=> vacuum;

VACUUM
test3=> insert into account (createdcons) values('current_timestamp');

INSERT 283384 1
test3=> insert into account (createdcons) values(current_timestamp());

ERROR:  parser: parse error at or near ")"
test3=> insert into account (createdcons) values(current_timestamp(now));

ERROR:  parser: parse error at or near "now"
test3=> insert into account (createdcons) values(current_timestamp('now'));
ERROR:  parser: parse error at or near "'"
test3=> insert into account (createdcons) values(now(current_timestamp));

ERROR:  No such function 'now' with the specified attributes
test3=> select * from account;

act|createdfunc                 |createdcons                 |created2cons|createdcurr
---+----------------------------+----------------------------+------------+-----------
y  |Thu Dec 02 12:51:59 1999 CST|Thu Dec 02 12:51:59 1999 CST|current     |current
1  |Thu Dec 02 12:52:03 1999 CST|Thu Dec 02 12:51:59 1999 CST|current     |current
Y  |Thu Dec 02 12:52:06 1999 CST|Thu Dec 02 12:52:06 1999 CST|current     |current
Y  |Thu Dec 02 12:52:13 1999 CST|Thu Dec 02 12:52:13 1999 CST|current     |current
Y  |Thu Dec 02 12:52:19 1999 CST|current                     |current     |current
Y  |Thu Dec 02 12:52:23 1999 CST|Thu Dec 02 12:52:23 1999 CST|current     |current
Y  |Thu Dec 02 12:52:26 1999 CST|current                     |current     |current
(7 rows)

    test3=> select * from account where createdcons = 'now';

    act|createdfunc                 |createdcons|created2cons|createdcurr
    ---+----------------------------+-----------+------------+-----------
    Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
    Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
    (2 rows)

    test3=> select * from account where createdcons = now();
act|createdfunc                 |createdcons|created2cons|createdcurr
---+----------------------------+-----------+------------+-----------
Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
(2 rows)

    test3=> select * from account where createdcons = 'current';

    act|createdfunc                 |createdcons|created2cons|createdcurr
    ---+----------------------------+-----------+------------+-----------
    Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
    Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
    (2 rows)

    test3=> select * from account where createdcons = 'current_timestamp';

    act|createdfunc                 |createdcons|created2cons|createdcurr
    ---+----------------------------+-----------+------------+-----------
    Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
    Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
    (2 rows)

    test3=> select * from account where createdcons = current_timestamp();

ERROR:  parser: parse error at or near ")"
test3=> select * from account where createdcons = current_timestamp('now');
ERROR:  parser: parse error at or near "'"
test3=> select * from account where createdcons = 'current_timestamp('now')';

ERROR:  parser: parse error at or near "now"
test3=> select * from account where createdcons = 'current_timestamp()';

act|createdfunc                 |createdcons|created2cons|createdcurr
---+----------------------------+-----------+------------+-----------
Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
(2 rows)

test3=> select * from account where createdcons = 'current_timestamp(now())';

act|createdfunc                 |createdcons|created2cons|createdcurr
---+----------------------------+-----------+------------+-----------
Y  |Thu Dec 02 12:52:19 1999 CST|current    |current     |current
Y  |Thu Dec 02 12:52:26 1999 CST|current    |current     |current
(2 rows)

test3=>


#############################################################
On Thu, 2 Dec 1999, Bruce Momjian wrote:

> Can you resend the results you had.  I can't see the difference.
>
>
> > no. "CURRENT_TIMESTAMP" is the same as "current", which
> > is very very different from "now", which, in turn, also
> > delicately different from "now()" .
> >
> > "current" is not very usefule. If you put "current" in db,
> > it remains there, until when you retrieve the dada, i.e.,
> > it is the "retrieve time". while "now" is our fmailiar
> > "modified time".
> >
> > conclusion: you were right in you book! keep using "now()".
> > (except in where-clause, you should use "now" instead)
> > -- until the now-'feature' is fixed, after that, we can use
> > "now" everywhere).
> >
> > remaining questions: 1) is the behavior of "now" in create
> > table a bug or feature?
> > 2) is "CURRENT_TIMESTAMP" = "current" a bug or not? --
> > need a real sql92 lover here. anybody idea?
> >
> > Kai
> >
> > On Thu, 2 Dec 1999, Bruce Momjian wrote:
> >
> > > > Here is the test. I did not put it in mail because pine did not like
> > > > cut/paste. now I find a way to do it. It looks good!
> > > > the conclusion: current_timestamp is "current" -- it should be,
> > > >    the looks closer than now/now()  :-)
> > >
> > > So CURRENT_TIMESTAMP is the same as now(), right?
> > >
> > > --
> > >   Bruce Momjian                        |  http://www.op.net/~candle
> > >   maillist@candle.pha.pa.us            |  (610) 853-3000
> > >   +  If your life is a hard drive,     |  830 Blythe Avenue
> > >   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
> > >
> >
> >
>
>
> --
>   Bruce Momjian                        |  http://www.op.net/~candle
>   maillist@candle.pha.pa.us            |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
>


pgsql-general by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [GENERAL] "FATAL 1: my bits moved right off the end of theworld!"
Next
From: Ed Loehr
Date:
Subject: Re: [GENERAL] Date & Time