• pspkshah (5/29/2015)


    Hello friends,

    how can I get time difference of the following record please help,

    STARTTIME ENDTIME

    3:30 PM 4:30PM

    7:30 PM 8:30PM

    I have tried it by below query,

    SELECT CONVERT(TIME,STARTTIME,108) - CONVERT(TIME,ENDTIME,108) FROM BATCH_MASTER

    but it gives following error message

    Operand data type time is invalid for subtract operator.

    ''

    Are there date columns that go with each of these times? I ask because if someone has a start time of, say, 11:00 PM and an end time of 06:00 AM the next day, you're going to run into a wee bit of a problem. There's a work around but having date associated with each time would make this a whole lot easier.

    --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)