pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brandon Metcalf <bmetcalf@nortel.com>
To: Martín Marqués <martin@bugs.unl.edu.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: query for records based on date
Date: Mon, 21 Feb 2005 14:48:00 -0600 (CST)
Message-ID: <Pine.LNX.4.58L.0502211447320.24449@cash.rhiamet.com> (raw)
In-Reply-To: <200502211742.55144.martin@bugs.unl.edu.ar>
References: <Pine.LNX.4.58L.0502211356580.24449@cash.rhiamet.com>
	<200502211742.55144.martin@bugs.unl.edu.ar>

m == martin@bugs.unl.edu.ar writes:

 m> El Lun 21 Feb 2005 17:00, Brandon Metcalf escribió:
 m> > If I have a table with an attribute of type "timestamp without time
 m> > zone", what is the best way to query that table for records that are
 m> > older than, say, one week.
 m> >
 m> > I suppose I could get the current time in epoch seconds and the time of
 m> > the attribute in the same, and select those records where the difference
 m> > is greater than the number of seconds in a week.  Is there something
 m> > easier like
 m> >
 m> >   SELECT * FROM table WHERE attribute IS OLDER THAN one week;

 m> SELECT * FROM table WHERE attribute < (now()::DATE - 7)::TIMESTAMP;


Thanks.


-- 
Brandon



view thread (4+ messages)  latest in thread

Message-ID: <Pine.LNX.4.58L.0502211447320.24449@cash.rhiamet.com>
Permalink:  ../Pine.LNX.4.58L.0502211447320.24449@cash.rhiamet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.58L.0502211447320.24449@cash.rhiamet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bmetcalf@nortel.com, martin@bugs.unl.edu.ar
  Subject: Re: query for records based on date
  In-Reply-To: <Pine.LNX.4.58L.0502211447320.24449@cash.rhiamet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox