Time Formula

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I need a little boost ...

Rich (BB code):
cmnshiftdur = Round((ecend - lcstart) * 24, 1)
tdiff = cmnshiftdur / 2

cmnshiftdur is the number of hours of overlap of two shifts
tdiff is half that value

I am failing in thought as to how to ...

Rich (BB code):
.Cells(DR, 2) = the value of ecend (end time of shift as a time value) - tiff formatted as "h:mm a/p" 


So if ecend = 3:00PM and tdiff = 1.5, the value in .Cells(DR, 2) = 1:30P
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I tried this,

Code:
.Cells(DR, 2) = format(DateAdd("m", tdiff, ecend), "h:mmA/P")
but am getting a result of 3:00PM.

Anyone?
 
Last edited:
Upvote 0
tdiff needs dividing by 24 if it is a decimal 1.5 as it would in the formula below


Excel 2010
ABC
23:00 PM13:30:00
31.5
Sheet1
Cell Formulas
RangeFormula
C2=A2-A3/24


and no need to use dateadd as it is a simple arithmetic sum
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,039
Members
448,940
Latest member
mdusw

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