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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
This seems way too complicated:

[Table="width:, class:grid"][tr][td] [/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][/tr]
[tr][td]
1​
[/td][td]
Sunset​
[/td][td]
Close​
[/td][td]
[/td][/tr]

[tr][td]
2​
[/td][td]
17:00​
[/td][td]
17:30​
[/td][td]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")[/td][/tr]

[tr][td]
3​
[/td][td]
17:01​
[/td][td]
17:30​
[/td][td][/td][/tr]

[tr][td]
4​
[/td][td]
17:15​
[/td][td]
17:30​
[/td][td][/td][/tr]

[tr][td]
5​
[/td][td]
17:16​
[/td][td]
18:00​
[/td][td][/td][/tr]

[tr][td]
6​
[/td][td]
17:39​
[/td][td]
18:00​
[/td][td][/td][/tr]

[tr][td]
7​
[/td][td]
17:40​
[/td][td]
18:30​
[/td][td][/td][/tr]

[tr][td]
8​
[/td][td]
17:59​
[/td][td]
18:30​
[/td][td][/td][/tr]
[/table]
 
Upvote 0
This seems way too complicated:

[Table="width:, class:grid"][tr][td] [/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][/tr]
[tr][td]
1​
[/td][td]
Sunset​
[/td][td]
Close​
[/td][td]
[/td][/tr]

[tr][td]
2​
[/td][td]
17:00​
[/td][td]
17:30​
[/td][td]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")[/td][/tr]

[tr][td]
3​
[/td][td]
17:01​
[/td][td]
17:30​
[/td][td][/td][/tr]

[tr][td]
4​
[/td][td]
17:15​
[/td][td]
17:30​
[/td][td][/td][/tr]

[tr][td]
5​
[/td][td]
17:16​
[/td][td]
18:00​
[/td][td][/td][/tr]

[tr][td]
6​
[/td][td]
17:39​
[/td][td]
18:00​
[/td][td][/td][/tr]

[tr][td]
7​
[/td][td]
17:40​
[/td][td]
18:30​
[/td][td][/td][/tr]

[tr][td]
8​
[/td][td]
17:59​
[/td][td]
18:30​
[/td][td][/td][/tr]
[/table]

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,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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