Lets say I have two shifts at work.
Day shift is from 7:00 to 17:30
Night shift is from 18:00 to 4:30
Based on this numbers I want excel to return if its "Night Shift" or "Day Shift"
This is what i have so far with the IF statement
=IF(Q2>=7,"DAY SHIFT",IF(Q2<=17.3,"DAY SHIFT",IF(Q2>=18,"NIGHT SHIFT",IF(Q2<4.3,"NIGHT SHIFT"))))
But im not getting the results I want. Any ideas to correct the formula?
The following is what you are looking for, assuming that cell Q2 is a Date/Time value.
=IF(AND(MOD(Q2,1)>=(7/24),MOD(Q2,1)<=(17.5/24)),"Day Shift",IF(OR(MOD(Q2,1)<(4.5/24),MOD(Q2,1)>=(18/24)),"Night Shift",""))
The MOD(Q2,1) extracts the time portion of a date/time cell. These values are stored as decimal numbers, where 4:30 AM would be represented by 4.5/24 = 0.1875 (note that 30 minutes is half an hour, hence 4:30 AM is represented by 4.5/24 instead of 4.3/24, which would be 4:18 AM).
This should work:
=IF(AND(Q2>=7,Q2<=17.5),"DAY SHIFT", "NIGHT SHIFT")
But if you want to specify the "Night Shift", this would be better:
=IF(AND(Q2>=7,Q2<=17.5),"DAY SHIFT", IF(OR(Q2>= 18, Q2<4.5), "NIGHT SHIFT",""))
A little shorter:
=IF(OR(Q2<4.5/24,Q2>=3/4),"Night",IF(AND(Q2>=7/24,Q2<=17.5/24),"Day","?"))&" Shift"
Related
Im using PivotTables and PivotCharts for a Dynamic Dashboard in Excel. Currently i have 3 shifts at work that i'd like to visualize but for that to happen i must:
Extract the time from a "Date & Time Cell" which im doing by using
=A2 - INT(A2) . No problem here
Create a nested IF AND formula to check whether the hour fits in any of theses shifts:
15:00 - 23:00 , 23:00 - 7:00 , 7:00 - 15:00
Im using this:
=IF(AND(E2>=TIME(15,0,0),E2<TIME(23,0,0)),"3-
11",IF(AND(E2>=TIME(23,0,0),E2<TIME(7,0,0)),"11 - 7","7 - 3"))
But it mixes up the shifts, its showing only 3-11 & 7-3 shifts, as if it couldn't distinguish between am and pm... im missing the 23:00 - 7:00 shift
From the TIME documentation:
The decimal number returned by TIME is a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.)
In other words, AND(E2>=TIME(23,0,0),E2<TIME(7,0,0) is equivalent (rounded to 2 decimal places) to AND(E2>=0.96,E2<0.29). So your second AND formula can only be false.
Either change that AND to OR, or flip your 2nd IF logic around:
...IF(AND(E2>=TIME(7,0,0),E2<TIME(15,0,0)),"7 - 3","11 - 7")
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.
In one column I have to 10 times and dates (I have merged date and time in a cell). How do I find top 5 earliest dates and times? I can’t use function MIN() because I have date and time together. How should I write the function?
You need to first format your data in date/time format in Excel.
Example, the following data is entered
16/7/2018 15:00
18/7/2018 12:05
25/8/2018 11:00
13/7/2018 09:00
15/7/2018 14:00
15/7/2018 11:00
You can use the formula =small(range, rank) to find the smallest n figure. For instance, =SMALL($A$1:$A$6,1) would give the smallest (earliest) date, 13/7/2018 09:00 in this case. =SMALL($A$1:$A$6, 2) would give the second smallest (earliest) date, 15/7/2018 11:00 in this case.
In Cell D$3$:D$38$ I have
## Heading ##
Thu Oct-05
Off
Off
Off
Maternity
Off
Off
Off
Off
Off
Off
VACATION
04:00-16:00
04:00-14:00
05:00-14:00
05:00-14:00
06:00-16:00
06:00-15:00
07:00-17:00
07:30-16:30
07:30-16:30
08:00-17:00
08:00-17:00
08:00-18:00
08:00-17:00
08:00-18:00
09:00-18:00
09:30-18:30
10:00-19:00
10:00-19:00
10:30-19:30
10:30-19:30
11:00-20:00
12:00-22:00
13:00-22:00
13:00-22:00
15:00-22:00
I used the formula
=SUMPRODUCT(--(ISNUMBER(TIMEVALUE(LEFT($D$3:$D$38,5)))))
to successfully obtain the result of 25 cells with number in the specified range but when I try to add a criteria like:
>=ISNUMBER(TIMEVALUE(B44)) and B44 is 4:00 am and the second criteria <=ISNUMBER(TIMEVALUE(c44)) B44 is 5:00 am
I'm not able to get the result I should that's: 2
Do you know why it is not working the way it should?
Thank You
You can change the formula to this:
=SUMPRODUCT(--(ISNUMBER(TIMEVALUE(LEFT(TEXT($D$3:$D$50,"hh:mm:ss"),5)))))
The reason it doesn't recognize 4:00 am or 5:00 am is due to TIMEVALUE evaluate time text and therefore, you need to convert it to time text first.
I have an Excel sheet with two date-time columns: Start Date and End Date. I need to calculate overtime by determining how many hours and minutes were worked before 08:00 and after 16:30.
Examples:
COLUMN A COLUMN B
1 2017/01/04 16:00 2017/01/04 18:00
2 2017/01/05 18:00 2017/01/05 21:00
3 2017/01/08 08:00 2017/01/08 17:00
4 2017/01/09 07:00 2017/01/09 09:00
I know the calculation for duration between times (=TEXT(B1-A1,"h:mm")), but I'm struggling to determine if a date-time is before 08:00 or after 16:30.
I've played around with TIMEVALUE("8:00:00"), TIMEVALUE("8:00:00 AM") and TIME(8,00,00) in my calculation, but the it did not work,
e.g. =IF(A1<=TIMEVALUE("8:00:00 AM"),"Yes","No") returns "No" even for A4 (2017/01/09 07:00)
I'm struggling with the calculation and the logic on this one. So far i'm using,
=IF(MOD(F2,1)<8/24,8/24-MOD(F2,1),0)+IF(MOD(G2,1)>16.5/24,MOD(G2,1)-16.5/24,0)
Try this:
=IF(TIMEVALUE(A1)<=TIMEVALUE("8:00:00 AM"),"Yes","No")
Stick with treating time as time; only treat time as text when you have bad data (time as text is bad data) and then only enough to get it to be time as time.
To get the number of hours and minutes before 08:00 AM,
=MAX(0, TIME(8, 0, 0)-TIMEVALUE(TEXT(A2, "hh:mm;0;#")))
To get the number of hours and minutes after 16:30 AM,
=MAX(0, TIMEVALUE(TEXT(B2, "hh:mm;0;#"))-TIME(16, 30, 0))
In the following image you can see that I have left one group as true time and the forced the following group to be time as text¹. Both return correct results.
¹ Unless specifically formatted otherwise, numbers and dates/times are right-aligned in a cell; text is left-aligned.