Re: JOIN and difference between timestamps

From: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
To: Conor McTernan <conormcternan(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: JOIN and difference between timestamps
Date: 2008-03-07 14:43:10
Message-ID: C3F6B09E.901FA%scott_ribe@killerbytes.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 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(at)killerbytes(dot)com
http://www.killerbytes.com/
(303) 722-0567 voice

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anton Melser 2008-03-07 14:45:07 Re: shared_buffers and shmmax what are the max recommended values?
Previous Message Greg Smith 2008-03-07 14:18:55 Re: shared_buffers and shmmax what are the max recommended values?