My company business hour is 7:30 to 18 and 13:00 to 15:00 is lunch time. Important part is about lunch time that should not calculate as working time of employee at all.
- So imagine employee start working at 8:30 and exit at 15:00 so the time of 4:30 hours should be calculate for him. actually I want to remove lunch time from attendance time of employee in different situations:
My fields are all in Time(7) format in Sql.
This is one approach in SQL Server. It fundamentally splits each person's shift into two - Pre-Lunch and Post-Lunch. When a shift goes into (or past) lunch, it uses the lunch times as the bounds instead.
I've also written it in bits (e.g., CTE, sub-query, etc) so you can run those individually to see what they do. It is likely you'll need to update it for your own database structures etc.
Here's a db<>fiddle
Issues: