Re: interval question

From: "Fernando P(dot) Schapachnik" <fernando(at)schapachnik(dot)com(dot)ar>
To: dev(at)archonet(dot)com
Cc: "Fernando P(dot) Schapachnik" <fernando(at)schapachnik(dot)com(dot)ar>, pgsql-general(at)postgresql(dot)org
Subject: Re: interval question
Date: 2001-03-06 22:35:41
Message-ID: 200103062235.f26MZgO00717@funes.schapachnik.com.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

En un mensaje anterior dev(at)archonet(dot)com escribió:
> On 3/6/01, 12:59:40 AM, Fernando "P." Schapachnik
> <fernando(at)schapachnik(dot)com(dot)ar> wrote regarding [GENERAL] interval question:
>
> > Hello:
> > Maybe somebody on the list can give me a hand with this. I
> > have:
> > id serial,
> > start time,
> > duration time
>
> Surely "duration" should be of type interval.
> Also - are you sure "start" should be time and not timestamp - depends if
> you don't care about dates.
>
> > (That is, ids have an start time and a duration).
>
> > I want to know which ids are current, ie, which satisfy
> > start<=now<=start+duration.
>
> SELECT id FROM foo WHERE start<=now() AND now<=(start + duration);

It worked fine! Thanks!

Fernando P. Schapachnik
fernando(at)schapachnik(dot)com(dot)ar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message GH 2001-03-06 23:13:09 Re: Inserting values into a SERIAL field
Previous Message Randy Hall 2001-03-06 22:10:02 Re: how to find DB names in Postgres 7.1?