Re: subtracting minutes from date - Mailing list pgsql-general

From Brandon Metcalf
Subject Re: subtracting minutes from date
Date
Msg-id Pine.LNX.4.58L.0602231525380.30715@cash.rhiamet.com
Whole thread Raw
In response to Re: subtracting minutes from date  (Scott Marlowe <smarlowe@g2switchworks.com>)
List pgsql-general
s == smarlowe@g2switchworks.com writes:

 s> On Thu, 2006-02-23 at 13:55, Brandon Metcalf wrote:
 s> > What is the best way to store a timestamp if all I need to do is
 s> > select rows where this timestamp is less than 60 minutes prior to the
 s> > current time?
 s> >
 s> > If I have a column called date with data type timestamp without time
 s> > zone I know I can use
 s> >
 s> >   SELECT * FROM table WHERE date < (now()::DATE - 7)::TIMESTAMP;
 s> >
 s> > to select rows where date is older than seven days.  I'm not quite
 s> > sure how to interpret now()::DATE::TIMESTAMP since I'm not able to
 s> > answer my own question.  I've tried things like:
 s> >
 s> >   SELECT * FROM table WHERE date < now()::DATE::(TIMESTAMP - 60);

 s> Tell it you're subracting a minute:

 s> select now() - interval '13 minutes';

Thanks.

--
Brandon

pgsql-general by date:

Previous
From: "Brandon Metcalf"
Date:
Subject: Re: subtracting minutes from date
Next
From: Emi Lu
Date:
Subject: Re: SQL TYPE MAP such as SQL_CHAR, SQL_NUMERIC , etc