On Mon, Mar 05, 2001 at 09:59:40PM -0300, Fernando P. Schapachnik wrote:
> Hello:
> Maybe somebody on the list can give me a hand with this. I
> have:
>
> id serial,
> start time,
> duration time
>
> (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.
>
> The problem is that start+duration is an interval, and I
> can't find the way to cast now to interval or interval to time or
> tinterval in order to make the comparison.
Maybe something like:
CREATE start_stop (
id SERIAL,
start DATETIME,
stop DATETIME
);
INSERT INTO start_stop (start, stop) VALUES (now(), now() + '1:00');
SELECT id from start_stop WHERE now() BETWEEN start AND stop;
--
Eric G. Miller <egm2@jps.net>