Excel working time calculation - excel

I am trying to put together an excel spreadsheet to track working time. A standard working day is say 8 hours with one hour lunch, say 40 hours total, 35 hours working. I need to track over and under time on a given day, and total this for a week period. The reason is to that if someone only takes a 30 minute lunch for three days, they can then take 1.5 hours off early at the end of the week for example.
Example daily record:
Mon - 9-6, 1 hour lunch = 8 working hours, 1 hour lunch, balance = 0 (the perfect day)
Tue - 8-6, 1 hour lunch = 9 working hours, 1 hour lunch, balance = +60 (one hour over)
Wed - 9-4, 1 hour lunch = 7 working hours, 1 hour lunch, balance = -60 (one hour under)
Thu - 9-6, 30 min lunch = 8 working hours, 30 min lunch, balance = +30 (30 mins over)
Fri - 9-6, 30 min lunch = 8 working hours, 30 min lunch, balance = +30 (30 mins over)
Example end of week totals
I am recording start/end/lunch times in excel in custom "time format" cells: 09:00 - 17:00
I am getting the hours with this formula: =TEXT(End-Start,"hh:mm")
I enter the lunch time in "time format" 00:30 (30 mins)
I get the actual time worked with this formula: =TEXT(Total-Lunch,"hh:mm")
When I try to add together / sum the values however I am not getting anything...
Any thoughts?

I do this with six columns
Date / Start / Lunch / Lunch / Stop / total
3-sep / 8:29 AM / 12:30 PM / 1:30 PM / 5:44 PM / 8.25
For total, I calculate with the function =MROUND((D5-C5+F5-E5)*24,0.25). This rounds the total to the closest 0.25 hour (that is, 15 min).
Just for kicks, I accumulate the excess hours. Excel will put in the current time by pressing Ctrl+Shift ; (semicolon).

Related

Calculate 30 hrs (24hrs+) time as single day in excel

I have a restaurant log in following format.
Date | Time | Bill Number | Item | Price | Total Orders
The store time is 11 Am to next day 5 am.
which will be over 24 hours.
But I want to calculate 11 am to next day 6 am as a single day.
Currently I am using Filter and sort to do it, but since data is of 2-3 months, is there a formula to sort it out?
For example
Jan 1st 11 am to Jan 2nd 6 am -> I want to calculate these time period as one day.
Solved it
using this
=TRUNC(B2+C2-TIME(6,0,0))

Allocating staff to 30 minute intervals

I’m trying to create either a spreadsheet or macro that allows me to put and employee start and finish time in and then show me by each half hour how many half hours they are in.
For example;
Employee 1 - 08:30 to 10:15
The output I would want is;
08:00 0
08:30 1
09:00 1
09:30 1
10:00 0.5
10:30 0
11:00 0
So between 8:30 and 9:00 shows as one because that employee was in during that half hour. But between 10:00 and 10:30 it shows 0.5 because the employee was only in for half of that period
Then as I add more data it tells me which half hours they are covering.
I’ve tried using the ceiling and floor values, counta, countif, countifs, v and hlookups but just can’t get the desired effect.
I’m guessing it would need to be a macro.
Assuming C1 and D1 contain the start and end times of a shift and column A contains the times, use the following formula in column B:
=IF(A2>D$1,C2,IF(AND(A2>=C$1,A3<=D$1),1,MAX(0,A3-D$1)/(1/48)))
Limitations: shifts cannot cross over days, days cannot start before 00:00 or end after 23:59

Excel Time Comparison and Subtraction

I am trying to do a time subtraction in excel of 30 minutes and I am running into a speed bump. So the table I have are as follows.
Table "Schedule"
Column 1 is day of the week (Mon-Sun) (formated as general, as this is plain text)
Column 2 is start time of the shift (formated as h:mm AM/PM)
Column 3 is end time of the shift (formated as h:mm AM/PM)
Column 4 is duration of the shift (start to end) (formated by formula (TEXT(col3-col2,"h:mm")) )
Column 5 is paid hours (if the total hours is over 6.5 then subtract 0.5 hours for an unpaid lunch) (formula IF(col5>"6:30",col5-"0:30",D5) )
The issue is any time allotment over 10 hours start to end (where column 4, the duration hits 10 hours) no lunch is subtracted at all.
So...
Start 9:00 AM, End 6:59 PM, Hours Total 9:59, Hours Paid 9:29
But...
Start 9:00 AM, End 7:00 PM, Hours Total 10:00, Hours Paid 10:00
and that should obviously not happen. I can't find anything on google so I figured the excel gurus here may have some advice.
Thanks!
If your time columns are stores using excel's dedicated time format, this should be straightforward. Mixed data types are likely your problem.
First, be sure your time columns (columns 2 and 3) are set using the time function, i.e.,
=time(hours,minutes,seconds)
Then, you should be able to add and subtract easily.
Column 4: = column 3 - column 2
... then subtract 30 minutes also using the time() function:
Column 5: = if(column 4 > time(6,30,0),column 4 -time(0,30,0),column 4)
Excel stores time values from 0 to 1. So 24 hours=1, 12 hours=.5 etc. That means 6.5 hours=0.270833333 and .5 hours=0.020833333. As a result you can just do a simple if statement.
=IF(D2>0.270833333,D2-0.020833333,D2)
To turn it into a time format, is to just use excel's time formating options.

How to display 1 hour 46 minutes in MS Excel cell where both the number count of hours and minutes comes from calculation?

Suppose I sleep for 7 hours and 36 minutes. I have a sleeping threshold of 5 hours and 54 minutes. If I sleep more than threshold time, I get the time difference and If i sleep less than or equal to my sleeping threshold, i get the output as 'You slept Good". To do so, I scaled zero to 60 minutes of actual time to 0 to 1 on a decimal scale, this way 7 hours 36 minutes comes as 7.6 and 5 hours 54 minutes comes as 5.9.
Now, I take their difference which comes out to be 1.7 i.e. I slept extra for 1 hour and 0.7 minutes on 0to1 scale (which equals 1 hour 42 minutes on actual time scale).
So, I used TRUNC function to display 1 h (i.e ! hour); however I can't get my mind working as to how I can display 42 minutes in the same cell.
i.e. my output should be 1h 42 min
This should work:
=IF(B2+C2/60>5.9,LEFT(B2+C2/60-5.9)& "hr "&ROUND(((B2+C2/60-5.9)-VALUE(LEFT(B2+C2/60-5.9)))*60,0)&"min","You slept good")
However, you wouldn't be able to do further calculations, as it is a text.
Also assumes you will not oversleep by more than 10 hrs :)

Search text column for certain strings and return the time in the cell, Excel

I work in a hospital and need to keep track of how much time and when I spend that time in different areas. Clinical and Research. There are multiple things that count as clinical hours though they are not the same thing. In the picture CFW, Clinic, AMJ, etc count as clinical. Training, Research, lunch, data, r383, experiment are not needed to keep track of. It appears like this:
___ A ____ B
1 8:30 Training
2 9:00 CFW
3 9:30 CFW
4 10:00 CFW
5 10:30 Clinic
6 11:00 Clinic
7 11:30 Research
8 12:00 Lunch
9 12:30 Data
10 1:00 AMJ
11 1:30 AMJ
12 2:00 AMJ
13 2:30 R383
14 3:00 Experiment
15 3:30 Experiment
16 4:00 Research
My end goal is to be able to have a list of text that I can search for, like "Clinic", and it tell me which times I was there and the total time spent, like 10:30-11:30 1 hour.
Clinic: 10:30-11:30
1 Hour
So if I search all of the text phrases it would have the times spent there (beginning - end), and the sum total length of time. I have a separate sheet for each day of the week and ideally would like to be able to search through all 5 sheets at once and have all the days pop up all organized and such.
For example:
Monday
Clinic: 10:30-11:30
1 Hour
AMJ: 1:00-2:30
1.5 Hours
Tuesday
CFW: 9:00-10:30
1.5 Hours
etc...
Sorry for my formatting. Let me know if I need to any more information. I'm not able to post the picture yet. Any ideas? Please and thank
You want to create a VBA Macro on your Excel Spreadsheet that will go through each sheet, look for what value you want (e.g. "Clinic"), capture your times and calculate the elapsed.
You can refer to each sheet, and the cells in loops. Here is a shell to get you started.
Public Function elapsedTime (byval searchFor As String)
Dim shIdx as Integer
Dim rIdx as Integer
Dim calc as Integer
rIdx = 2
For shIdx = 1 to 5
While Sheets(shIdx).Range("A" + CStr(rIdx)).Value <> ""
If Sheets(shIdx).Range("B" + CStr(rIdx)).Value = searchFor Then
Additional logic here to calculate your value and
store it in "calc"...
End If
rIdx = rIdx + 1
Wend
rIdx = 2
Next shIdx
elapsedTime = calc
End Function

Resources