Re: I was spoiled by the MySQL timestamp field - Mailing list pgsql-general

From will trillich
Subject Re: I was spoiled by the MySQL timestamp field
Date
Msg-id 20030124193611.GA21258@mail.serensoft.com
Whole thread Raw
In response to Re: I was spoiled by the MySQL timestamp field  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Fri, Jan 24, 2003 at 10:55:26AM -0500, Tom Lane wrote:
> Dennis Gearon <gearond@cvc.net> writes:
> > What's the difference between 'now()' and 'current_timestamp' ?
>
> None AFAIK.  now() is historical Postgres usage, CURRENT_TIMESTAMP is
> the SQL-spec-mandated spelling of the same functionality.
>
> CURRENT_TIMESTAMP with an argument does something a bit different,
> though.
>
> http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

the one caveat is outlined at the bottom of that very page:

    All the date/time data types also accept the special literal
    value now to specify the current date and time. Thus, the
    following three all return the same result:

        SELECT CURRENT_TIMESTAMP;
        SELECT now();
        SELECT TIMESTAMP 'now';

    Note: You do not want to use the third form when specifying
    a DEFAULT clause while creating a table. The system will
    convert now to a timestamp as soon as the constant is
    parsed, so that when the default value is needed, the ##TIME
    OF THE TABLE CREATION## would be used! The first two forms
    will not be evaluated until the default value is used,
    because they are function calls. Thus they will give the
    desired behavior of defaulting to the time of row insertion.

[emphasis mine]

so careful using "now" when you mean to use "now()".
or better yet, "current_timestamp" for consistency.

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

pgsql-general by date:

Previous
From: "Nigel J. Andrews"
Date:
Subject: Re: More PHP DB abstraction layer stuff
Next
From: Greg Stark
Date:
Subject: Re: More PHP DB abstraction layer stuff