From: | <kaiq(at)realtyideas(dot)com> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] Date & Time |
Date: | 1999-12-02 15:50:25 |
Message-ID: | Pine.LNX.4.10.9912020943400.19647-100000@picasso.realtyideas.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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() :-)
###############################################################
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 283346 1
test3=> insert into account values('1');
INSERT 283347 1
test3=> insert into account (createdcons) values(now());
INSERT 283348 1
test3=> insert into account (createdcons) values(now);
ERROR: Attribute now not found
test3=> insert into account (createdcons) values('now');
INSERT 283349 1
test3=> insert into account (createdcons) values(current);
ERROR: Attribute current not found
test3=> insert into account (createdcons) values('current');
INSERT 283350 1
test3=> insert into account (createdcons) values(current_timestamp);
INSERT 283351 1
test3=> insert into account (createdcons) values('current_timestamp');
INSERT 283352 1
test3=>
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=>
test3=> select * from account;
act|createdfunc |createdcons |created2cons|createdcurr
---+----------------------------+----------------------------+------------+-----------
y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:33 1999 CST|current |current
1 |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:33 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
(7 rows)
test3=> select * from account where createdcons = 'now';
act|createdfunc |createdcons |created2cons|createdcurr
---+----------------------------+----------------------------+------------+-----------
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
(5 rows)
test3=> select * from account where createdcons = now();
act|createdfunc |createdcons |created2cons|createdcurr
---+----------------------------+----------------------------+------------+-----------
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
(5 rows)
test3=> select * from account where createdcons = 'current';
act|createdfunc |createdcons |created2cons|createdcurr
---+----------------------------+----------------------------+------------+-----------
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
Y |Thu Dec 02 08:41:34 1999 CST|Thu Dec 02 08:41:34 1999 CST|current |current
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
(5 rows)
test3=> select * from account where createdcons = 'current_timestamp';
act|createdfunc |createdcons|created2cons|createdcurr
---+----------------------------+-----------+------------+-----------
Y |Thu Dec 02 08:41:34 1999 CST|current |current |current
Y |Thu Dec 02 08:41:34 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"
##############################################################
On Wed, 1 Dec 1999, Bruce Momjian wrote:
> > Ed Loehr ha scritto:
> >
> > > Just curious: anyone have any comment on any practical differences between now() and CURRENT_TIMESTAMP, which seems to work
> > > the same?
> > >
> >
> > I think it is the same function, both of them return the current date and time.
> >
> > now() should be the internal postgreSQL function.
> > and CURRENT_TIMESTAMP is the exact SQL-92 syntax
>
> I am changing my book to use CURRENT_TIMESTAMP rather than now().
>
> --
> Bruce Momjian | http://www.op.net/~candle
> maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ************
>
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Jewiss | 1999-12-02 16:48:34 | Upper/lower case passwords |
Previous Message | Moray McConnachie | 1999-12-02 15:15:55 | Re: [GENERAL] "FATAL 1: my bits moved right off the end of theworld!" |