It seems in your table you only have an "ending datetime", kind of like "my nightshift is reporting at 6:50 AM that 581 pcs have been produced".
Why not just add a "starting datetime"-column for the shift?
Kind of like: "I'm nightshift, and i start producing at 7:05 PM (hittingaBuzzer)" --> "I'm nightshift and ended at 6:54 AM and have produced 563 pcs (hittingaBuzzerAgain)"
Then you could query by the starting datetime