• The static dates are just examples. Substitute the correct column names.

    Shifting gears, to get the duration between two DATETIME datatypes, just subtract the smaller of the two from the larger of the two and format the result the way you want with CONVERT (good enough for durations < 24 hours) and other tricks (necessary if you have durations >= 24 hours.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)