Calculate Closing Time (Rounded to 1/2 Hour) Based on Sunset Time

Smokeyham

Board Regular
Joined
Feb 1, 2006
Messages
120
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to set up a system in Excel 2007 (running under Windows 7) to calculate a facility's closing time based upon "rules" about Sunset time. Using the very helpful information from exceldir I was able to download the Sunset times, and convert them using the formula =TIME(C8,D8,0).

Now I would like to use those times calculate the closing times based on two rules:

Rule #1
If sunset is between 20 minutes before the hour and 15 minutes after the hour, then set close time at the next ½ hour

Example: Sunset is between 5:40 PM and 6:15 PM then close time is 6:30 PM.

Rule #2
If Sunset is between 16 minutes after the hour and 39 minutes prior to the next hour, then set close time at the next full hour.

Example: Sunset is between 7:16 PM and 7:39 PM then close time is 8:00 PM.

Can anyone tell me a formula which would allow this to be calculated?

Thanks for any help!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
This seems way too complicated:

A​
B​
C​
1​
Sunset​
Close​
2​
17:00​
17:30​
B2: =CHOOSE(MATCH(MINUTE(A2), {0,1,16,40}), A2+"0:30", CEILING(A2, "0:30"), CEILING(A2, "1:00"), CEILING(A2, "1:00")+"0:30")
3​
17:01​
17:30​
4​
17:15​
17:30​
5​
17:16​
18:00​
6​
17:39​
18:00​
7​
17:40​
18:30​
8​
17:59​
18:30​
 
Upvote 0
This seems way too complicated:

A​
B​
C​
1​
Sunset​
Close​
2​
17:00​
17:30​
B2: =CHOOSE(MATCH(MINUTE(A2), {0,1,16,40}), A2+"0:30", CEILING(A2, "0:30"), CEILING(A2, "1:00"), CEILING(A2, "1:00")+"0:30")
3​
17:01​
17:30​
4​
17:15​
17:30​
5​
17:16​
18:00​
6​
17:39​
18:00​
7​
17:40​
18:30​
8​
17:59​
18:30​

Thanks so much! Exactly what I needed, and I really appreciate learning a new tool.
 
Upvote 0
You're welcome. I'll be embarrassed if barry houdini shows up.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top