Excel formula for bifurcating Time for calculating charges

shenoyg

New Member
Joined
Jan 19, 2016
Messages
4
Hi All,

First of all I want to Thank each one of you and this forum for the continued help on excel to many basic users like me. I have read many posts whenever I needed help on excel, without registering here previously and and those solutions have immediately solved my problems.

However this time around, I could not get to what I specifically want and hence seeking for help on this platform.

I have a vehicle parking facility where the charges are different for day and night. Hence what I want is:

I have IN time with date and time format example 1/20/2016 17:00:00 in I6 Cell
And I have a OUT time with same format example 1/21/2016 15:00:00 in I7 Cell

I need total parking hours from 06:00:00 hrs to 22:00:00 hrs in a cell, say J6 and
Total parking hours from 22:00:00 hrs to 06:00:00 in another cell J7

So that i can calculate the applicable charges for the respective hours

In the above Example: Cell I6 = 1/20/2016 17:00 to Cell I7 = 1/21/2016 15:00
The result i want in cell J6 is total day hrs = 14 and
The result I want in cell J7 is Total night hrs = 8

Any Help on the above problem is highly appreciated!

Thanks In Advance

Goutham
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi,

Quick bump but ok.

try this:
<b></b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">Blok 1</td><td style="text-align: right;;">06:00:00</td><td style="text-align: right;;">22:00:00</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">blok 2</td><td style="text-align: right;;">22:00:00</td><td style="text-align: right;;">06:00:00</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: center;;">Hours</td><td style="text-align: center;;">Rate</td><td style="text-align: center;;">Invoice</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: center;;">20-1-2016 17:00</td><td style="text-align: right;;"> 14,00 </td><td style="text-align: right;;"> $ 10,00 </td><td style="text-align: right;;"> $ 140,00 </td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: center;;">21-1-2016 15:00</td><td style="text-align: right;;"> 8,00 </td><td style="text-align: right;;"> $ 5,00 </td><td style="text-align: right;;"> $ 40,00 </td></tr></tbody></table><p style="width:6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1 (2)</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">J6</th><td style="text-align:left">=(<font color="Blue">(<font color="Red">NETWORKDAYS(<font color="Green">I6,I7,holidays</font>)-1</font>)*(<font color="Red">$C$1-$B$1</font>)+IF(<font color="Red">NETWORKDAYS(<font color="Green">I7,I7,holidays</font>),MEDIAN(<font color="Green">MOD(<font color="Purple">I7,1</font>),$C$1,$B$1</font>),$C$1</font>)-MEDIAN(<font color="Red">NETWORKDAYS(<font color="Green">I6,I6,holidays</font>)*MOD(<font color="Green">I6,1</font>),$C$1,$B$1</font>)</font>)*24</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">J7</th><td style="text-align:left">=(<font color="Blue">(<font color="Red">I7-I6+(<font color="Green">I7<I6</font>)</font>)*24</font>)-J6</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">L6</th><td style="text-align:left">=K6*J6</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">L7</th><td style="text-align:left">=K7*J7</td></tr></tbody></table></td></tr></table><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Workbook Defined Names</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Name</th><th style="text-align:left">Refers To</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">holidays</th><td style="text-align:left">=Sheet1!$A$7:$A$14</td></tr></tbody></table></td></tr></table><br />
 
Upvote 0
Hello Sir,

Thank you so much for your time and response.

I have tried your solution above and works for 1 or 2 date differences. but as the start date and end date difference is increased, the formula seems to be giving erratic calculations

For example: I tried using these figures as start date and end date

Start date: 1/17/2016 17:00:00
End date: 1/19/2016 11:00:00

This Ideally should give me a result of 26 day hours in J6 and 16 night hours in J7 cells respectively.
But result it is giving me is 21 and 21 in J6 & J7 respectively.
However, the total time difference is 42, which is correct.

Request for further help on this.

Warm regards,
Goutham
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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