• Thanks for your quick answers ...

    Mark, I have test You code.

    In original, it calculates the WorkingTimeMinutes for each shift and day.

    Depending of that my table contains many other records, I made a small modification, like

    ..

    WHERE t.Code = 1

    -- my added code

    and t.dtBegin >= '2013-06-11 12:40:21' and t.dtBegin <= '2013-06-12 08:59'

    to limit the output.

    The result I got then was, of natural things, not correct, because it's select from the next coming shift, etc.

    If we as example use the values from my first post, how could I use them for get a correct calculation ?

    dtStart : '2013-06-11 12:40:21'

    dtStop : '2013-06-12 08:55:16'

    If I calculated it "by hand", I came to that the summary of the WorkingTimeMinutes should be 781, when using the values described above.

    In some way the "dtStart" should be used for the first calc, and the "dtStop" at last calc.

    But how fix this in the query ??