Search Postgresql Archives

Re: subtracting minutes from date

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

 



s == smarlowe@xxxxxxxxxxxxxxxxx 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


[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