First, a clarification. Excel starts with 1 for Sunday, not zero, and runs
up to 7 for Saturday. I was thinking of a different language.
First thing to do, probably, is work out whether you have an exact number of
weeks - simply check for a remainder from the division of the period by 7.
If there isn't a remainder, then you can just take the integer result of the
division as the number of weekends. If there is a remainder, you still use
the integer result as the number of weekends covered by whole weeks. You
only need to handle a possible partial-week weekend, or possibly just an
orphan Saturday or Sunday.
I suspect that the following will work:
- if the end day of week is the same as the start day of week, then you have
an extra 24 hours if that day is a Sat or Sun
else
- if the end day of week is greater than the start day of week, then you
might have one or two weekend days - add 24 if the start day is Sun and an
extra 24 if the end day is Sat
else (the end day of week is less than the start day of week)
- you have a whole extra weekend (I think) - add 48