now() and interval

From: "Travis Hoyt" <thoyt(at)npc(dot)net>
To: "Postgres" <pgsql-novice(at)postgresql(dot)org>
Subject: now() and interval
Date: 2002-04-03 15:06:00
Message-ID: DBEMKMGOMJAGKAKEPPEGEELGDIAA.thoyt@npc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Just curious, why does this date manipulation return the incorrect value
based on the order of the operation?

output from now() for reference for below:

mydb=> select now();
now
------------------------------
2002-04-03 10:02:23.52309-05
(1 row)

mydb=> select interval '1 month' + now();
?column?
---------------------
2002-04-03 00:00:00
(1 row)

mydb=> select now() + interval '1 month';
?column?
-------------------------------
2002-05-03 10:02:44.038337-04
(1 row)

I can only assume it's because now() overwrites some values? Is this
supposed to work this way?

Travis

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-04-03 16:03:54 Re: now() and interval
Previous Message Ivan Horvath 2002-04-03 14:20:07 Re: Transactions in Postgres