difference between two time ( 24 hours format)

khikha1

New Member
Joined
Jun 10, 2020
Messages
22
Office Version
  1. 365
Platform
  1. Windows
dear all

i am calculating difference between two times ( 24 hours format ) , as per attach i am facing a problem when the time is moving from night to morning hours ( check orange color ) , i also attached the format i am using.

hope you can assist with this . thanks in advance .
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You cannot attach files to your posts. However, you can post screen images.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
dear all

i am calculating difference between two times ( 24 hours format ) , as per attach i am facing a problem when the time is moving from night to morning hours ( check orange color ) , i also attached the format i am using.

hope you can assist with this . thanks in advance .
my apologies attached is the data.
 

Attachments

  • 24FM2.png
    24FM2.png
    70 KB · Views: 10
Upvote 0
You cannot attach files to your posts. However, you can post screen images.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
noted sir . i replied and attach a snapshot .
 
Upvote 0
That is because Excel doesn't like negative times, and you are trying to subtract a larger number from a smaller ones.
Excel actually stores dates/times as numbers, specifically the number of days since 1/0/1900.
So days are just numbers/integers, and time is just the fractional part of one day.

If you have Start Date in cell K2 and End Date in cell J2, this formula would handle all cases:
Excel Formula:
=IF(K2<J2,(K2+1)-J2,K2-J2)
 
Upvote 0
Modular arithmetics should work.
Excel Formula:
=MOD(K2-J2,1)
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,102
Members
453,021
Latest member
Justyna P

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