Skip to content
Advertisement

How to calculate hours that a clinic is open taking into account break times

I am using MariaDB 10.3.

I am attempting to derive how many hours a clinic is actually open for a given weekday from an provider schedule table.

The clinic is considered “closed” if (1) all providers are at lunch or (2) no providers are scheduled to work at that time.

If at least one provider is still working while the others are at lunch, the clinic is considered “open”.

Consider this clinic with four providers and a schedule from Monday to Wednesday.

Fiddle: https://www.db-fiddle.com/f/GvkvRKwaZ3Eeusj77CA4J/0

Advertisement

Answer

Consider the following…

Then, crudely…

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement