Second Dose Advisor testing.xlsx

I am doing an informatics project for a nursing program and attempting to create a calculation that will advice nurses whether a medication is due to be given or not.

The rule is very simple however the math involved often confuses nurses:

If the amount of time between the last dose given and the next scheduled administration time is GREATER than or equal to ½ of the ordered dosing interval, the dose should be administered at the next scheduled dosing time.
Example 1:
A patient is ordered for 500 mg Flagyl IVPB q 8 hours (Standard Administration Times: 6:00 A.M.-2:00 P.M.-10:00 P.M.) at 3:00P.M. The first dose is given at 5:00 P.M. When should the next dose be given?
Answer:
Half of q 8 hours is 4 hours. The next scheduled administration time is 10:00 P.M. which is 5 hours from the first dose that was given at 5:00 P.M. (10:00. - 5:00 = 5 hours). Since this time is GREATER than 4 hours, give the next dose at 10:00 P.M. as scheduled.

If the amount of time between the last dose given and the next scheduled administration time is LESS than ½ of the ordered dosing interval, the next scheduled dose would be skipped and the regular scheduled administration times would resume thereafter.
Example 2:
A patient is ordered for 1 Gram of Vancomycin IVPB STAT and q 12 hours (Standard Administration Times: 6:00 A.M. and 6:00 P.M.) at 1:00 A.M. The STAT dose is given at 1:30 A.M. When should the next dose be given?
Answer:
Half of q 12 hours is 6 hours. The next scheduled administration time is 6:00 A.M. which is 4.5 hours from the STAT dose that was given at 1:30 A.M. (6:00 – 1:30 = 4.5 hours). Since this is LESS than 6 hours, skip the 6:00 A.M. scheduled dose and give the next scheduled dose at 6:00 P.M.
At first glance my calculator seems to give the correct answer. However as it gets later in the day and the next dose would be due the next morning or at midnight the math can get kind of fuzzy. The only way I can think to overcome this is to enter the entire date in the calculator (month date year hour minute) which would decrease the effectiveness of the calculator since it would take far longer to enter information.

Can anyone think of an easy way to make this work? Perhaps adding a variable if the next dose is due midnight or after?

Any help is much appreciated.