Is there a way to reset all the date in a cell to

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I have a big problem, I want to be able to calculate the number of hours between two dates in two cells, now this works fine as long as the time in each cell is not midnight or beyond, if it goes over midnight for some reason the calculation adds 21 days as you can see below:
I assume this has something to do with the formula I use which is simply:
Code:
=F2-E2
but I don't know what to do about it, I can figure out its because the dates show the end time as before the starttime in effect but I can't think of a way to get around it as not all the time are after midnight!
below is an example of what I mean

EFGH
1startendhow sum is caculatedhours caculated
2 00/01/1900 00:000:00
300/01/1900 12:0000/01/1900 20:0000/01/1900 08:008:00
400/01/1900 08:0000/01/1900 16:0000/01/1900 08:008:00
500/01/1900 16:0000/01/1900 00:0023/01/1900 08:00560:00
600/01/1900 08:0000/01/1900 14:0000/01/1900 06:006:00
700/01/1900 00:00 00/01/1900 00:000:00
800/01/1900 06:0000/01/1900 14:0000/01/1900 08:008:00
900/01/1900 06:0000/01/1900 13:3000/01/1900 07:307:30
1000/01/1900 00:00 00/01/1900 00:000:00
1100/01/1900 18:0000/01/1900 00:3023/01/1900 06:30558:30
1200/01/1900 08:0000/01/1900 16:0000/01/1900 08:008:00
1300/01/1900 12:0000/01/1900 20:0000/01/1900 08:008:00
1400/01/1900 00:00 00/01/1900 00:000:00
1500/01/1900 00:00 00/01/1900 00:000:00

<COLGROUP><COL style="WIDTH: 54pt" width=72><COL style="WIDTH: 96pt; mso-width-source: userset; mso-width-alt: 4096" width=128><COL style="WIDTH: 101pt; mso-width-source: userset; mso-width-alt: 4288" width=134><COL style="WIDTH: 113pt; mso-width-source: userset; mso-width-alt: 4800" width=150><COL style="WIDTH: 116pt; mso-width-source: userset; mso-width-alt: 4928" width=154><TBODY>
</TBODY>
THIS IS JUST A SNIPPET, the sheet is much large in columns and rows.

as you can see, column g shows a date and 8:00 hours the 8:00 is correct but the date is messing up when I'm trying to add these calculations together.
Now as you can imagine I'm looking to get the result of between 10:30pm and 00:30am being 2 hours, but I'm getting the calculation between the dates as well.
Now is there a way to say ignore the date just calculate the number of hours between these two days?
or if not is there a way to reset the dates in a cell back so they all show as 00/01/1900? (but not all the dates will be the same)
or can I manipulate the end date in some way so the calculation works?
I don't mind how its done but please someone help me I've been on this for over 8 hours now totally stuck!
I'm really stuck,
please help

thanks

Tony
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Brilliant! MOD did the job thank you so much,
had to play around with the formula a bit but got the result I needed and couldn't do it without you so thank you,
P.S. in case anyone else has the same problem the formula I used was this:
Code:
=MOD(G3-F3+(F3>G3)*24,1)
thanks for you help guys.

Tony
 
Upvote 0
Hi, it just wasn't giving me the number of hours, it was giving me something else, maybe I'm wrong and I was just looking at it wrong but it didn't seam to give me the hours worked.
but I couldn't have sorted it without your help, so thank you very much, I only thought I'd post the solution I used in case anyone else had the same problem, I wasn't trying to criticise your formula so sorry if it read that way. I was so stuck and you gave me the answer in just a few minutes. very grateful
Thanks

Tony
 
Upvote 0

Forum statistics

Threads
1,214,576
Messages
6,120,354
Members
448,956
Latest member
Adamsxl

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