Date Time formula assistance needed

Dennisr53

New Member
Joined
May 29, 2015
Messages
38
Hi Everyone,

I am in need of assistance I have a spreadsheet that is in Military time and need to calculate the difference between two cells. See example below:

A B C D E
1 Enttered Date Entered Time Collected Date Collected Time subtract collected date and time from entered date and time
2 7/10/2015 0 7/9/2015 2359 formula is ? To get the difference in H:MM format
3 7/27/2015 1540 7/27/2015 1500

4 7/6/2015 2356 7/8/2015 2333 sometimes this is a negative H:MM but I get ########
this is military time this is military time

0 is actually 00:00 or midnight


Any help is greatly appreciated.

Thanks,
Dennis
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You need to add the time to the dates and then do the subtraction:

Excel 2010
ABCDEF
210/07/2015009/07/2015235900:01
327/07/2015154027/07/2015150000:40

<tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
F2=($A$2+(INT(B2/100)*60+((B2/100-INT(B2/100))*100))/24/60)-($C$2+(INT(D2/100)*60+((D2/100-INT(D2/100))*100))/24/60)

<tbody>
</tbody>

<tbody>
</tbody>

Blue = Date
Red = Hours converted into minutes
Orange = Minutes
Green = Time Conversion.

This could probably be simplified.
 
Last edited:
Upvote 0
Comfy, Thank you for the quick response. I have tested the formula and it works great except is does not give me a negative ( - 0:40 ) time value as in my row 2 and row 3 example. The entered date and time is after the collected date and time so it should be a negative hours and minutes.

Any suggestions how to display the negative time>

Thanks again,
Dennis
 
Upvote 0
kvsrinivasamurthy Thanks for the assist. With your formula I have the same issue as my response to Comfy's formula. It will not display a negative time difference in H:MM format as is in row 2 and 3 of my example. This is a big dilemma for me as I am doing stats on the results.

Thanks again,
Dennis
 
Upvote 0
Only display is required or is it used for further calculation.Because negative time can only be displayed can not be used for calculation.
 
Upvote 0
Only display is required or is it used for further calculation.Because negative time can only be displayed can not be used for calculation.

I was hoping to use it in calculation of average time but display would be fine. I can come up with another way to include it in avg time.
 
Upvote 0
Use Two columns E & F
In E2 use the same formula and format the column for Number. Time will be displayed in number (positive and negative) . this can be used for all calculation.
Code:
=A2+INT(B2/100)/24+MOD(B2,100)/(24*60)-C2-INT(D2/100)/24-MOD(D2,100)/(24*60)
In F2 Use the formula. Time will be displayed in text format.
Code:
=IF(E2<0,"-","")&INT(ABS(E2)*24)&":"&TEXT(INT(MOD(ABS(E2)*24,1)*60),"00")
Both formulas can be dragged down.
 
Last edited:
Upvote 0
Use Two columns E & F
In E2 use the same formula and format the column for Number. Time will be displayed in number (positive and negative) . this can be used for all calculation.
Code:
=A2+INT(B2/100)/24+MOD(B2,100)/(24*60)-C2-INT(D2/100)/24-MOD(D2,100)/(24*60)
In F2 Use the formula. Time will be displayed in text format.
Code:
=IF(E2<0,"-","")&INT(ABS(E2)*24)&":"&TEXT(INT(MOD(ABS(E2)*24,1)*60),"00")
Both formulas can be dragged down.


Thank you. This will work for me. I appreciate the help.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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