• L' Eomot Inversé (9/15/2012)


    Unless there is some performance issue that I haven't spotted, it should be sensible to do this the simple and obvious way:

    SELECT LoadNumber

    FROM LoadTimes

    WHERE (@Now >= StartTime AND (@Now < EndTime OR StartTime >= EndTime))

    OR

    (@Now <= EndTime AND EndTime < StartTime)

    I can't see that adding or subtracting 12 hour chunks buys you anything useful, the calculation is just as complex if you do that.

    Turns it all into scans instead of seeks. May not matter in this case.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon