Search Postgresql Archives

Re: Interval Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Terry Lee Tucker <terry@xxxxxxxx> writes:
> I thought that subtracting the larger interval from 
> the small would return this but it is always the absolute value.

Eh?

regression=# set DateStyle TO ISO;
SET
regression=# select '@ 3 days 4 hours 17 mins'::interval -
regression-# '@ 3 days 6 hours 17 mins'::interval;
 ?column?
-----------
 -02:00:00
(1 row)

regression=# set DateStyle TO postgres;
SET
regression=# select '@ 3 days 4 hours 17 mins'::interval -
regression-# '@ 3 days 6 hours 17 mins'::interval;
   ?column?
---------------
 @ 2 hours ago
(1 row)

and as for detecting whether it's negative,

regression=# select ('@ 3 days 4 hours 17 mins'::interval -
regression(# '@ 3 days 6 hours 17 mins'::interval) < '0'::interval;
 ?column?
----------
 t
(1 row)

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux