Re: subtracting minutes from date

From: "Brandon Metcalf" <bmetcalf(at)nortel(dot)com>
To: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: subtracting minutes from date
Date: 2006-02-23 21:25:52
Message-ID: Pine.LNX.4.58L.0602231525380.30715@cash.rhiamet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

s == smarlowe(at)g2switchworks(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Emi Lu 2006-02-23 21:31:14 Re: SQL TYPE MAP such as SQL_CHAR, SQL_NUMERIC , etc
Previous Message Brandon Metcalf 2006-02-23 21:25:35 Re: subtracting minutes from date