time that crosses mid night

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
Someone worked from 10:00pm to 6:00am next day. I want to calculate the difference. So I tried

A1=10 pm
B1= 6 am

C1=(A1-B1)*24

But did not work

I watched a video and the guy said use =Mod((B1-A1),1)

But did not explain why. I know what mod is used for but how this idea came from? Mod is used for totally something else.

Another question please:

1 am in excel is basically 1/24

what do you call 1/24? and what do you call (1/24)*24

Thank you very much
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Evaluate the formulas; you can use Excel's Formula Evaluate

N.B. 1 day is 24 hours
12 hours is .5 of a day
8 hours is 1/3 ie .3333 of a day



Excel 2010
ABCD
122:006:008
222:006:008
3
41/24fraction of a day 1/24 or 1 hour
51one hour
6
3d
Cell Formulas
RangeFormula
C1=MOD(B1-A1,1)*24
C2=(B2-A2+(A2>B2))*24
A5=1/24*24
 
Upvote 0
Thank you for your help and reply. Let me explain to you what I understood and please correct me if I am wrong.

Mod() will return the number if the number is less than 1. Not only returns the number but change the sign to + if the number is negative

Mod(0.5,1) = 0.5
Mod(-0.5,1) = 0.5

So using Mod is basically to get rid of the negative when I subtract AM time from PM time crossing midnight. Am I right?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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