• You are right about the <= comparison. I was using <= for the join condition, and just changed it to <.

    JOIN cteTally t ON p.StartTime < DATEADD( dd, DATEDIFF( dd, 0, p.EndTime), -t.n + 1)

    The results look good now:

    MachineCalDay HoursPerDay

    22015-09-01 00:00:00.000 2.000000

    22015-09-02 00:00:00.000 24.000000

    22015-09-03 00:00:00.000 20.000000

    32015-09-01 00:00:00.000 2.000000

    32015-09-02 00:00:00.000 24.000000

    32015-09-03 00:00:00.000 22.000000

    42015-10-01 00:00:00.000 2.000000

    42015-10-02 00:00:00.000 22.000000

    52015-09-01 00:00:00.000 10.000000

    62015-11-06 00:00:00.000 24.000000

    62015-11-07 00:00:00.000 6.283333