How to check if a time noted is within designated window or range in Excel - excel

I need to check if a time of collection is within allowed time window or not.
For e.g.
A B C
1 10.36 10.30 1 min out of +/- 5 minutes window
2 10.24 10.30 1 min out of +/- 5 minutes window
A1 here time of collection of data, and B1 is the scheduled time. The acceptable window or range for this is +/- 5 minutes out of window. In this case the time of collection is 1 min out of +/- 5 minutes window. Similar example is shown in row 2. How can i get C1 to show the message as above which can account for + 5 minutes and - 5 minutes scenarios?.
Thanks in advance.

=IF(ABS(A1-B1)>(5/1440),"Problem!","OK")
5/1440 is 5 minutes (1440 minutes in a full day)

Use this formula¹ in C1 and fill down as necessary,
=ROUND(MAX((ABS(A1-B1)-0.05)*100, 0), 0)
Use the following custom number format on column C,
0 \mi\n out of ± 5 \mi\nut\e wi\n\dow
The advantages of a custom number format is that the numbers remain numbers and are available for future calculations (e.g. SUM, AVERAGE, etc) while displaying the text you wish to show. Note the right-alignment in the cells indicating true numbers.
¹ This formula depends on the time values being mixed numbers and not true time. If the time values are true time with a non-EN-US number format then additional maths may have to be applied to the formula.

Related

Adding/Subtracting Whole numbers from Time

I have tried every which way to format cells to subtract the result from time for instance the formula in the cell = 11(this is 11 minutes) I want to take that result minus 8:00:00 to give me 7:49:00 but it doesn't work the result is ####### no matter how big I make the cell. And if I format the cells with the formula to custom [m]:ss then the value changes.
Sample of the Worksheet:
I want Y2 = X3-W3 in a time format.
So, if A1=11
Then in some other cell, (B1 in this example): =TIME(,A1,)
Then subtract from the cell with 8:00:00. (If it's C1...:)
=C1-B1
That will give you the time you want.
Info: The main thing is that you have to tell Excel that your cell with the "11" in it, is minutes. By using the =TIME(,A1,) you will get the value of: 12:11 am. (If you keep it in Date format.) 12:11 am could also be viewed as: 0 Hours, 11 minutes, 0 seconds. And now that it knows, you should be able to subtract.
Try this:
=TIME(HOUR(X3),MINUTE(X3)-W3,SECOND(X3))
The ######### is because you have a negative time. Becuase Excel reads time as decimals of 24 hours, 8:00:00 is .3333 and if you subtract 11 from that you get -10.6666 and date/time can not be negative.

Computing Average In MM:SS in excel

Input: Minutes:Seconds
Output: Average in Minutes:Seconds
I currently have a sheet where we put in handle times for calls. We want to compute the average handling time in minutes:seconds. Now, currently we have minutes in Column A and seconds in Column B. In Column C, I convert A&B to total seconds. In Column D, I use =AVERAGE(C1:C6) to compute for average.
Question: Do we have an easier way to doit? Specifically, is there any formula that will allow me to simply input Minutes:Seconds in a single column and have the average in Minutes:Seconds to be calculated?
Option 1:
(If you can change your input format):
You need to set the data format as hh:mm:ss
Inputting the data in this format will allow excel to automatically detect the format and as such, allow for you to use the 'average' formula.
For example, if you have 3 entries for: 2 minutes, 1 min 30 secs and 1 minute, the data in col A should look like:
00:02:00
00:01:30
00:01:00
You can then run, for example, the formula:
=AVERAGE(A1:A3)
Note: By default, putting the data in the format "xx:yy", excel will assume that xx is the hours and yy is the minutes, so you should pass the initial 00: if you don't have your time in hours
Option 2:
(If you cannot change your input format):
If you need to stick to the format where col A contains the minutes and col b contains the seconds, you can use the following formula to pass "hh:mm:ss" data in col c:
=(A1/(24*60))+(B1/(24*60*60))
(default date value is set to '1 day' for a cell, so we divide by 24 hrs and 60 mins to convert it to 'minutes' from col A and 24*60*60 to get seconds from col B)
You can then use a folmula similar to the one below to calculate the average time in col C:
=AVERAGE(C1:C3)
Note: You would need to set column C to the 'Custom format':
hh:mm:ss

Convert 'x hrs y min z sec' to seconds

a) So I have a huge folder of .csv data with a column about time duration where the cells are 'x min y sec' (e.g. 15 min 29 sec) or 'x hrs y min z sec' (e.g. 1 hrs 48 min 28 sec). The cells are formatted by text.
I want to batch change them to the number of seconds, but I have no idea where to start. I can't get the data in another format.
I thought about somehow using 'hrs', 'min' or 'sec' as delimiters, but I don't know how to move from there. I also thought about using ' ' as delimiters, but then the first column is filled with either hours or minutes depending on the time duration.
I also thought about using PostgreSQL's SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'), but I haven't been able to work out how to use this on a column from a table.
b) Is there a better way to change this time format 'Fri Mar 14 11:29:27 EST 2014' to epoch time? Right now I'm thinking of using macros in Excel to get rid of 'Fri' and 'EST', then put the columns back together, then use the to_timestamp function in PostgreSQL.
In Excel if you have data in only those 2 formats and starting from A2 you can use this formula in B2 copied down to get the number of seconds:
=IFERROR(LEFT(A2,FIND("hrs",A2)-1)*3600,0)+SUM(MID(0&A2,FIND({"min","sec"},0&A2)-3,2)*{60,1})
It finds the relevant text then gets the number in front for each and multiplies by the relevant number to get seconds
You can do:
SELECT EXTRACT(EPOCH FROM column_name::interval)
FROM my_table;
The interval can use the regular time units (like hour), abbreviations thereof (hr) and plurals (hours). I am not sure about a combination of plural and abbreviation (hrs) though. If that does not work, UPDATE the column and replace() the sub-string "hrs" to "hours".
If you want to save the number of seconds in your table, then you convert the above statement into an UPDATE statement:
UPDATE my_table SET seconds_column = extract(epoch FROM column_name::interval);
I would split with space as the delimiter, then examine the second column. If it contains the string "hrs", then your seconds answer is:
3600 * column 1 + 60 * column 3 + column 5
Otherwise it is:
60 * column 1 + column 3

Increase time by milliseconds in Excel

I have a certain value of time(10:00:00:00) and I have 1000 samples in excel for one minuit till
(10:00:01:00) which means every time interval to every sample is 0.06 second.
How could add 0.06 second to 10:00:00:00 incrementally till reach to 10:00:01:00 in excel
10:00:00:00 AM
10:00:00:06
10:00:00:12
10:00:00:18
:
:
10:00:59:54
10:00:01:00
hint: I need the formula of time in milliseconds due to big data samples for 24 hours and every hour has 1000 samples which means 24000 samples.
Say that:
Cell A1 contains start time: 10:00:00.00 AM
Cell Z1 contains constant: 00:00.06
Cell A2 will be: =A1+$Z$1
Then you can drag down A2...

Excel VBA to count records that have a certain number of elapsed seconds

I am trying to report "Number of Elapsed Seconds" in these breaks: Less than 15 minutes, 15 to 19 min, 20 to 24 min, 25 to 29 min, 30 to 45 min, 45 to 60 min, and 60 min or more.
I have a field that shows elapsed seconds and I am able to get the breaks I want -- In Total -- by using the following formula:
=SUMPRODUCT((ABS(TestTable!$AF$2:$AF$50)>=0)*(ABS(TestTable!$AF$2:$AF$)<=899))
(where 'TestTable' is the sheet where the data is located and Col AF is where elapsed seconds is stored). The problem?
I need to cut each break down by another field. Also in 'TestTable' is a field with either PRODx or PRODz in it (it's Col H).
So I need to say "If Col H = PRODx, then count how many records are less than 15 min and put it in a certain cell ---THEN--- if Col H = PRODz then count how many records are less than 15 min and put that result in a different cell".
Anybody know a way to write this?
if you have excel 2007 or later, COUNTIFS should work out for you.
=COUNIFS(H:H,AF:AF,"<900",H:H,"PRODx") for less than 15 mins, and PRODx
=COUNIFS(H:H,AF:AF,"<900",H:H,"PRODz") for less than 15 mins, and PRODz
then for the ranges you expand the selection
=COUNIFS(H:H,AF:AF,">=900",AF:AF,"<1200",H:H,"PRODx") for 15-19 mins, and PRODx
=COUNIFS(H:H,AF:AF,">=900",AF:AF,"<1200",H:H,"PRODz") for 15-19 mins, and PRODz
keep repeating this for all the ranges of time/PRODs that you need
In cell A1, type:
=COUNT(IF(H:H="PRODx",IF(AF:AF="Less Than 15 Seconds",M1:M5)))
M is just another random column
In cell A2, type the same, but change PRODx to PRODz.
Make sure to enter all formulas as an array formula, by hitting CTRL + SHIFT + ENTER after typing, instead of just enter.
See this link for more: Count If WIth Multiple Criteria
EDIT
If you must have a VBA solution, let me know. Otherwise, you don't need VBA. Also, if you are running Excel 2007 or above, you can use the CountIfs function, which will be cleaner and less resource intensive than the Array formula above.

Resources