blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:
I have an application that is looking up values from a time schedule. Depending on when the lookup is run it is possible to wrap around from say 23:00 past midnight in the list of desired values. I want to keep the rows sorted by relative time with the wrapped around (does that term make sense?) rows kept as being chronologically after the pre midnight rows.
I've come up with a brute force method, anymonk out there have an elegant way of doing this?
The data is stored in a PostgreSQL database with a schema that looks sorta like this (confidential info has been obfuscated).
create sequence event_id_seq; create table schedule ( event_id integer not null default nextval('event_id_seq'), event_start time not null, event_end time not null, event_descriptor varchar(50) not null, primary key (event_id) );
The application in one mode looks for events that happen within a window starting at an arbitrary time plus 3 hours and in the other mode looks for the next "n" events from an arbitrary time.
These are daily scheduled events where the schedule might change every 3 months or so. The end application schedules other events to happen in lead of the events retrieved. IE if an event as happening at 23:10 the other event has to happen at 22:50 (30 minutes prior) and is used to schedule activities of some employees.
Anybody have ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Midnight wraparound.
by Corion (Patriarch) on Aug 12, 2005 at 20:15 UTC | |
|
Re: Midnight wraparound.
by Transient (Hermit) on Aug 12, 2005 at 20:56 UTC | |
|
Re: Midnight wraparound.
by kwaping (Priest) on Aug 12, 2005 at 21:01 UTC | |
|
Re: Midnight wraparound.
by Anonymous Monk on Aug 12, 2005 at 20:41 UTC | |
|
Re: Midnight wraparound.
by JamesNC (Chaplain) on Aug 13, 2005 at 13:29 UTC | |
|
Re: Midnight wraparound.
by Anonymous Monk on Aug 14, 2005 at 04:02 UTC |