Re: subtratcing dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fran Fabrizio <ffabrizio(at)exchange(dot)webmd(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: subtratcing dates
Date: 2001-05-05 02:19:18
Message-ID: 3811.989029158@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Fran Fabrizio <ffabrizio(at)exchange(dot)webmd(dot)net> writes:
> I want to have a query that tells me whether or not the timestamp is
> within 'limit' minutes of the current time.

A poorly documented fact is that you can coerce an integer number of
seconds into a reltime, which can then be added to or subtracted from
a timestamp. So:

select tstamp > now() - reltime(limit*60) from ...

should do it.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2001-05-05 02:24:24 Re: Data conversion question
Previous Message Justin Clift 2001-05-05 02:11:45 Re: Daylight savings