now() and interval - Mailing list pgsql-novice

From Travis Hoyt
Subject now() and interval
Date
Msg-id DBEMKMGOMJAGKAKEPPEGEELGDIAA.thoyt@npc.net
Whole thread Raw
Responses Re: now() and interval  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

Attachment

pgsql-novice by date:

Previous
From: Ivan Horvath
Date:
Subject: Re: Transactions in Postgres
Next
From: Tom Lane
Date:
Subject: Re: now() and interval