Re: [SQL] datediff function

From: "tjk(at)tksoft(dot)com" <tjk(at)tksoft(dot)com>
To: tpham(at)mail(dot)priority(dot)net (Pham Thinh)
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] datediff function
Date: 1999-08-16 23:26:07
Message-ID: 199908162326.QAA23987@uno.tksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Clayton Cottingham 1999-08-16 23:41:51 Re: [SQL] example of a simple function
Previous Message Bruce Momjian 1999-08-16 23:20:10 Re: [SQL] example of a simple function