pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tjk@tksoft.com <tjk@tksoft.com>
To: tpham@mail.priority.net
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] datediff function
Date: Mon, 16 Aug 1999 16:26:07 -0700 (PDT)
Message-ID: <199908162326.QAA23987@uno.tksoft.com> (raw)
In-Reply-To: <551413BBBB03D111BF880060B01AACCE139F30@home.priority.net>

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." 



Troy

> 
> Hi everyone,
> 
> Does anyone know if postgres has a function similar to what datediff does in
> mssql server? I need it to do an update similar to the one below:
> 
> "update schedule set purged = 0 where datediff(day, timein, getdate()) > 30"
> 
> I know i could pull the whole table down to my machine, modify the data and
> then upload it back, but that's really stupid not to mention what it'll do
> to network trafic.
> 
> Thank you very much for any answer,
> Thinh
> 
> 




view thread (12+ messages)  latest in thread

Message-ID: <199908162326.QAA23987@uno.tksoft.com>
Permalink:  ../199908162326.QAA23987@uno.tksoft.com/
Also on:    postgresql.org/message-id/199908162326.QAA23987@uno.tksoft.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: tjk@tksoft.com, tpham@mail.priority.net
  Subject: Re: [SQL] datediff function
  In-Reply-To: <199908162326.QAA23987@uno.tksoft.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