Search Postgresql Archives

Re: JOIN and difference between timestamps

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

 



> I understand that subtraction of timestamps will return an interval,
> but I cannot tell if it is in seconds or minutes.

Neither. Because an interval can represent things like '1 year' or '1 month'
which cannot be represented as a simple number of seconds or minutes. So
what you want is:

 timestampcol1 - timestampcol2 <= '1 hour' and timestampcol2 - timestampcol1
<= '1 hour'

Because intervals can be negative...

BTW, you can figure out some of these things in psql, by trying things like
"select '2008-03-06 08:00:00':timestamp - '2008-03-06 09:00:00'::timestamp;"


-- 
Scott Ribe
scott_ribe@xxxxxxxxxxxxxxx
http://www.killerbytes.com/
(303) 722-0567 voice



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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