Working with dates, times, hours & min.

EdNerd

Active Member
Joined
May 19, 2011
Messages
456
Transcribing time data into a worksheet & having trouble getting the formats and values I need for formulas.

I have a start date and time and end date and time. All four values are in different (but sequential) columns. I need to use these values to get the total time lapsed (the time extends overnight, so the end date is always greater and the time is always less).

Then I have four columns of blocks of time (hours & min, though it may be 0 hrs); these need to be added to verify they make up the entire time block, and each block needs to be calculated as a percentage of the whole.

Any help is greatly appreciated!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Please upload Example file & Desired Results with XL2BB ADDIN (Preferable) OR upload at free hosting site e.g. www.dropbox.com, GoogleDrive or OneDrive then Input link here.
For Cumulative hours Use custom format and type: [h]:mm
 
Upvote 0
Awesome add-in!!! I want to be that smart some day!

Here is the sheet I am currently using. These are times for total and stages of sleep. The date is the wake-up date, so it pairs with the AM time; the date for the PM time is always a day earlier.
The end goal is to have actual times for all the totals and the stages, as well as percentages of a whole, that I can look at on a chart.
Theresa Fitbit Sleep.xlsx
ABCDEFGHIJKLMN
1Date (Woke up)StartStopScoreAwakeREMLightDeepTotalAwakeREMLightDeepTotal
21/3/20219:42 PM8:25 AM861.152.365.471.59.281hr, 15mn2hr, 36mn5hr, 47mn1hr, 5mn9hr, 28mn
31/2/202110:11 PM8:28 AM871.162.324.361.539.11hr, 16mn2hr, 32mn4hr, 36mn1hr, 53mn9hr, 1mn
41/1/202112:43 AM9:25 AM751.282.243.71.437.141hr, 28mn2hr, 24mn3hr, 7mn1hr, 43mn7hr, 14mn
Sheet1
Cell Formulas
RangeFormula
J2:N4J2=CONCATENATE((LEFT(E2,1)),"hr, ",(RIGHT(E2,IF(LEN(E2)=3,1,2))),"mn")
 
Upvote 0
Your data is not clear. If you enter the information as time, the example shown below may help.

Date and Time 2021.xlsm
ABCDEFGHIJKLM
1DateStartStopTimeScoreAwakeREMLightDeepAwakeREMLightDeep
21-Jan-2121:4208:2510:430:302:365:471:504.7%24.3%54.0%17.1%
32-Jan-2122:1108:2810:171:162:324:361:5312.3%24.6%44.7%18.3%
1a
Cell Formulas
RangeFormula
J2:M3J2=F2/$D2
D2:D3D2=C2-B2+(B2>C2)
 
Upvote 0
Solution
For some reason, I thought you could only subtract times that covered more than one day if the value included the date: mm/dd/yy hh:mm. So one stumper was how to pull the Col A and Col B values together (in a formula or in another cell) to create that value. That doesn't have to be done?

I don't understand your formula in D2: =C2-B2+(B2>C2) ?? What does the (B2>C2) expression do? I've never seen it used like that.
 
Upvote 0
Did you try the formula?

What does the (B2>C2) expression do?
If the time spans midnight (times like 10:00 PM to 7:00 Am), the expression is True which evaluates to 1 and the calculation yields the correct time.
see example below and an alternative
Edit The formulas that I posted also convert the time to decimal. instead of 7:30 it would show 7.5

T201810c.xlsm
ABC
122:006:008
222:006:008
3d
Cell Formulas
RangeFormula
C1C1=MOD(B1-A1,1)*24
C2C2=(B2-A2+(A2>B2))*24
 
Upvote 0
Yes, I did try it, and saw that it worked. It just seemed unnatural to add a "greater than" operation. But if it's TRUE, then you're adding 1, which gives the correct answer. Like I said, I never saw it used like that before.

Thank you for all your help on this!!
Ed
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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