RE: [SQL] datediff function

From: "Pham, Thinh" <tpham(at)mail(dot)priority(dot)net>
To: "'pgsql-sql(at)postgreSQL(dot)org'" <pgsql-sql(at)postgreSQL(dot)org>
Subject: RE: [SQL] datediff function
Date: 1999-08-17 13:18:55
Message-ID: 551413BBBB03D111BF880060B01AACCE139F34@home.priority.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

What happen if i just want to compare using minute only or hour only instead
of day? Is there a function to do that or is postgres only work in day?

T.

> -----Original Message-----
> From: Herouth Maoz [mailto:herouth(at)oumail(dot)openu(dot)ac(dot)il]
> Sent: Tuesday, August 17, 1999 6:05 AM
> To: tjk(at)tksoft(dot)com; tpham(at)mail(dot)priority(dot)net
> Cc: pgsql-sql(at)postgreSQL(dot)org
> Subject: Re: [SQL] datediff function
>
>
> At 02:26 +0300 on 17/08/1999, tjk(at)tksoft(dot)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
>
>
>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Herouth Maoz 1999-08-17 13:28:44 RE: [SQL] datediff function
Previous Message Herouth Maoz 1999-08-17 11:13:34 Re: [SQL] Stepping through a table.