pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: tjk@tksoft.com <tjk@tksoft.com>
To: tpham@mail.priority.net
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] datediff function
Date: Tue, 17 Aug 1999 14:05:02 +0300
Message-ID: <l03130300b3def2007db9@[147.233.159.109]> (raw)
In-Reply-To: <199908162326.QAA23987@uno.tksoft.com>
References: <551413BBBB03D111BF880060B01AACCE139F30@home.priority.net>

At 02:26 +0300 on 17/08/1999, tjk@tksoft.com wrote:


>
> I think what you are looking for is age()
> E.g.
>
> "update schedule set purged = 0 where age('now',dayin) > timespan('30
>days'::reltime)"
>
> Presuming a table such as this:
>
> create table schedule (purged int, dayin datetime);
>
> This replaces "day" and "timein" with "dayin."

Basically correct, but if there is an index on dayin, it won't be used. The
best query to do would be

WHERE dayin > 'now'::datetime - '30 days'::timespan;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (12+ messages)  latest in thread

Message-ID: <l03130300b3def2007db9@[147.233.159.109]>
Permalink:  ../l03130300b3def2007db9@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130300b3def2007db9@[147.233.159.109]

 · 

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: herouth@oumail.openu.ac.il, tjk@tksoft.com, tpham@mail.priority.net
  Subject: Re: [SQL] datediff function
  In-Reply-To: <l03130300b3def2007db9@[147.233.159.109]>

* 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