For reporting I export raw data from a pbx in CSV. There are many columns with data. Relevant for this case is:
Column A: Date of the events (there are many events on a same day)
Column B: Length of the events in seconds
Column C: Date + Timestamp of every event
I filter out all events shorter or equal to 90 seconds,
I am able to adjust the range by changing dates in 2 cells I created for this occasion (start date is in D1 & end date is in cell D2). Without integarting time I use:
=COUNTIFS(B:B;">=90";A:A;">="&D1;A:A;"=<"&D2)
It works like a charm. I select a range in cells D1 & D2 and I automatically get all the events between these dates excluding events shorter or = to 90 sec.
On top of this I need to know how many events / occurrences happen between certain timestamps. For example from November 1st till November 7th I need to know how man events happened between 12:00h and 13:00h, how many happened between 15:00h & 18:00h etc.
Logically I thought that just adding another criteria_range and criteria (in this example column C) would do the trick. Alas adding column C does not seem to work and I have spinned it many ways.
My intuition is that the DATE + TIME format is inadequate, innapropriate for my case.
Column C looks like this: 02/11/2015 21:59:47
Being european, I'm happy with the DD/MM/YYY notation, but it seems that no formula can take account of the TIME and neglect the DATE in front. Remember I already use column A for the dates. Here in column C I am interested in the TIMESTAMP.
Any aideas or suggestions are welcome.
Thank you very much in advance.
PS: I can always split the time from the date using text to column feature. Yet It means I will be formatting the raw exports and I would like to avoid that at all costs so that I can just copy paste new exports in my control sheet without having to do all sorts of formatting.
Without sample data it is difficult to tell whether you are treating the elapsed time as 90 seconds (integer) or 00:01:30 (as true seconds, a decimal portion of 1). Your formula seems to indicate the elapsed time as an integer but it is also wrong in other places (e.g. =< instead of <=) so the only thing for certain is that it is not a working formula. The same goes for determining the time window. Are you comparing it to 12 and 13 as integers or 12:00:00 and 13:00:00 as true time? They are decidedly NOT the same thing.
The SUMPRODUCT function can provide the cyclic processing required to treat a datetime as time only (e.g. MOD(C2:C12, 1)) or as an integer representing the hour of the day (e.g. HOUR(C$2:C$12)).
The formulas in F2, F5 and F7 are,
=COUNTIFS(B:B; ">="&E2; A:A; ">="&E3; A:A; "<="&E4)
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(MOD(C$2:C$12; 1)>=E5)*(MOD(C$2:C$12; 1)<=E6)*(B$2:B$12>=E$2))
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(MOD(C$2:C$12; 1)>=E7)*(MOD(C$2:C$12; 1)<=E8)*(B$2:B$12>=E$2))
If E5 and E6 were 12 and 13 instead of 12:00:00 and 13:00:00 then the formula in F5 would be,
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(HOUR(C$2:C$12)>=E5)*(HOUR(C$2:C$12)<=E6)*(B$2:B$12>=E$2))
Related
I am using a spreadsheet to record the intervals between certain medical events. Each event's timestamp is recorded in one column, so the interval between each event is the difference between consecutive cells (and the time since the last event uses now()).
First problem: I want to display the interval in days, hours and minutes. None of the built-in formats will do this, they report the days remaining after discarding complete months. So I am using this expression:
TEXT(TRUNC(C2-C1),"0") & " days " & TEXT(MOD(C2-C1,1),"hh "" hrs "" mm ""mins""")
which (e.g.) shows "46 days 13 hrs 44 mins". I was hoping there was a way to format a date/time value to show this rather than making the cell a string value, but I haven't been able to find one.
Second problem: I want to display the average value of all completed intervals in the same format. Because I can't average the string values produced by the previous expression I need to average the numeric equivalent (which I'd prefer not to have visible in the sheet) and then convert it to a string as for a single interval.
I can probably do this with a similar approach (if I don't run out of characters to enter the formula) but it seems to me that there must be a better way.
Ideally there is a solution which will work in Excel 2010. Has anyone solved a similar problem before and can give me some pointers?
Thanks, T
Edit: Some data to show what I am working with (I hope the image is readable). Here's a few lines from the sheet.
The formula for H2 etc. is
=IF(G2="c",NOW()-C2,"")
I5 is calculated as the difference between C5 and Cprev (where prev is chosen so that D5 and Dprev are both set). Obvious extension of this for J and K.
M2, M3 and M4 are respectively
=AVERAGEIF(K5:(INDIRECT("K"&(ROWS(K:K)))),"<>0")
=AVERAGEIF(J5:(INDIRECT("J"&(ROWS(J:J)))),"<>0")
=AVERAGEIF(I5:(INDIRECT("I"&(ROWS(I:I)))),"<>0")
Now, I can use a custom format for the values in H, I and J, and for M3 and M4, because these values will never exceed a few days. But values in K and M2 will be somewhere around 100 so I can't just format the raw value.
With custom formatting applied:
Here K6 and M2 say "27 days.." not "87 days..". That's what I'd like to fix nicely, hopefully without populating additional cells or writing a 3gl function to do it.
Date_Times in Excel are stored as days (with the decimal part representing parts of a day).
If the date matters, rather than just a number of days, then day zero is 1899/12/31.
Your first thought was right - do with formatting, not by turning a number into a string.
Entering date into A and time into B, with C=A+B is a good start, so that you can E.g. subtract one point in time from another without having to do anything about straddling midnight, month-ends etc, calculate averages etc.
Consolidating the comments already here: per https://support.microsoft.com/en-us/office/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309 you cannot get d for days above 31 (and it won't accept a format 0 hh:mm:ss )
I suggest that you do all your calculations using just numbers to get to say column M, and in N2 put =M2 etc, so you have the same values twice.
Then for formatting, use Format Cells | Number | Custom.
In column M put 0 "days".
In column N put hh "hours" mm "minutes".
I'm currently performing analysis on some data. Basically, sorting different product by certain variables, all this in different time frames (product flow every 30 minutes).
My date and time column looks like this: 2.01701E+11 (201701262230).
How do I refer to it?
Thank you.
Thank you for the prompt answer, but I still don't quite get how to use it. I've tried but failed.
Basically imagine I have a column with products (A, B, C, D) and next to them a column with daytimevalues that start at 13 o'clock on a certain day (201701241300) and end at 11PM the same day (201701242300). The range changes each 30 minutes.
I am trying to count all product A on the 24th of January at 13:00, and then at 13:30 and so forth:
the formula would go something like this:
=COUNTIFS(Data[Product_type], "A", Data[day_hour], ??????????)
=DATEVALUE(TEXT(A1,"0000-00-00 00\:00")) this fromula will get you the date.
=TIMEVALUE(TEXT(A1,"0000-00-00 00\:00")) this formula will give you the time.
A1 is the cell containing the input value
In the Image the column C and D contains the above mentioned formula...
=COUNTIFS($A$2:$A$10,F3,$C$2:$C$10,$G$1,$D$2:$D$10,(">=13:00:00"),$D$2:$D$10,("<14:00:00"))
you can use the above formula in cell G3 to get desired output...similarly you can use it to get other values as well.
enter image description here
You can see the situation here. Basically I have the dates under that form. I need to count the countries by occurence in time, every have hour in a given day.
I have cells with duration, specified as hours:minutes:seconds.
1726:48:00
410:10:00
599:20:00
The first line means 1726 hours, 48 minutes and 00 seconds
The second line means 410 hours, 10 minutes and 00 seconds
The third line means 599 hours, 10 minutes and 00 seconds
How do I sum these times in Excel, to get a breakdown in days, hours, minutes and seconds?
I'm afraid that might be impossible by changing the cell format.
If your number is in A1, you could use one of these 2 formulas:
=ROUNDDOWN(A1,0)&TEXT(A1," hh:mm:ss")
=INT(A1)&TEXT(A1," hh:mm:ss")
I also tried =TEXT(A1,"0")&TEXT(A1," hh:mm:ss"), but TEXT(A1,"0") sometimes does roundup which is not welcome.
The drawback of those formulas is that they return text. So you'll not be able to use the results in further calculations.
The requirement is to add a range of cells containing values called “duration”, which are expressed in Date and Time Serial Numbers and to display the result, currently formatted as [h]:mm:ss, in days, hours, minutes and seconds, (a kind of format [d] hh:mm:ss which is not allowed by the Excel application as already explained by ZygD). ZygD also proposed to use a formula to display the desired result as a text which comes with the restriction of further use in other calculations as well explained by ZygD:
=INT(A1)&TEXT(A1," hh:mm:ss")
In case that the total expressed as text needs to be expressed back as a Date and Time Serial Numbers I suggested the formula:
=SUM(LEFT(B1,-1+SEARCH(" ",B1)),
SUBSTITUTE(B1,LEFT(B1,SEARCH(" ",B1)),""))
Now if this does not satisfy the requirement there is another solution, that allows to add the Date and Time Serial Numbers showing the result as “days, hours, minutes and seconds” provided that it’s acceptable to show the result in two separated cells using the following formulas:
Values with “duration” are placed in the range C4:C6,
Totals Days in cell "C10",
Total Hours in cell "C11"
Totals Days =INT(SUM($C$4:$C$6))
Total Hours =MOD(SUM($C$4:$C$6),1)
If the totals are needed for further use just use the standard "SUM" formula to add up both, see cell C13
=SUM(C10,C11)
The "original" value can be worked backwards from ZygD's formula using the following formula:
=SUM(LEFT(B1,-1+SEARCH(" ",B1)),
SUBSTITUTE(B1,LEFT(B1,SEARCH(" ",B1)),""))
I'm doing some benchmarking, and I want to use Excel to produce graphs of the results. I've got a simple but annoying problem which is baking my noodle.
The problem is that Excel insists that "time" means a time of day. It refuses to let me work with time durations. When I try to say "three minutes and six seconds", it misinterprets this as "three minutes and six seconds past midnight", which isn't what I meant at all.
I can work around the problem by laboriously converting everything to seconds. But then all my graphs are labelled in seconds, not minutes and seconds. Plus it's a pain to have to keep typing in =3*60+6 rather than just 3:06. And once I've done it, I have to look at the formula to check whether I entered the data correctly [and didn't screw up the formula].
Does anybody know how I can make Excel work with a time duration not anchored to a specific time of day?
You can easily do this with the normal "Time" data type - just change the format!
Excels time/date format is simply 1.0 equals 1 full day (starting on 1/1/1900). So 36 hours would be 1.5. If you change the format to [h]:mm, you'll see 36:00.
Therefore, if you want to work with durations, you can simply use subtraction, e.g.
A1: Start: 36:00 (=1.5)
A2: End: 60:00 (=2.5)
A3: Duration: =A2-A1 24:00 (=1.0)
Use format d "days" h:mm:ss or [h]:mm:ss, depending on your needs.
Say you have a duration of 30h 12m 54s:
h:mm:ss -> 6:12:54 (not correct for a duration)
[h]:mm:ss -> 30:12:54
d "days" h:mm:ss -> 1 days 6:12:54
Variations are possible: I like something like d"d" h"h" mm"m" ss"s" which formats as 1d 6h 12m 54s.
The custom format hh:mm only shows the number of hours correctly up to 23:59, after that, you get the remainder, less full days. For example, 48 hours would be displayed as 00:00, even though the underlaying value is correct.
To correctly display duration in hours and seconds (below or beyond a full day), you should use the custom format [h]:mm;# In this case, 48 hours would be displayed as 48:00.
Cheers.
With custom format of a cell you can insert a type like this: d "days", h:mm:ss, which will give you a result like 16 days, 13:56:15 in an excel-cell.
If you would like to show the duration in hours you use the following type [h]:mm:ss, which will lead to something like 397:56:15. Control check: 16 =(397 hours -13 hours)/24
I don't know how to make the chart label the axis in the format "X1 min : X2 sec", but here's another way to get durations, in the format of minutes with decimals representing seconds (.5 = 30 sec, .25 = 15 sec, etc.)
Suppose in column A you have your time data, for example in cell A1 you have 12:03:06, which your 3min 6sec data misinterpreted as 3:06 past midnight, and column B is free.
In cell B1 enter this formula: =MINUTE(A1) + SECOND(A1)/60 and hit enter/return. Grab the lower right corner of cell B2 and drag as far down as the A column goes to apply the formula to all data in col A.
Last step, be sure to highlight all of column B and set it to Number format (the application of the formula may have automatically set format to Time).
Highlight the cell(s)/column which you want as Duration, right click on the mouse to "Format Cells". Go to "Custom" and look for "h:mm" if you want to input duration in hour and minutes format. If you want to include seconds as well, click on "h:mm:ss". You can even add up the total duration after that.
Hope this helps.
The best way I found to resolve this issue was by using a combination of the above. All my cells were entered as a Custom Format to only show "HH:MM" - if I entered in "4:06" (being 4 minutes and 6 seconds) the field would show the numbers I entered correctly - but the data itself would represent HH:MM in the background.
Fortunately time is based on factors of 60 (60 seconds = 60 minutes). So 7H:15M / 60 = 7M:15S - I hope you can see where this is going. Accordingly, if I take my 4:06 and divide by 60 when working with the data (eg. to total up my total time or average time across 100 cells I would use the normal SUM or AVERAGE formulas and then divide by 60 in the formula.
Example =(SUM(A1:A5))/60. If my data was across the 5 time tracking fields was the 4:06, 3:15, 9:12, 2:54, 7:38 (representing MM:SS for us, but the data in the background is actually HH:MM) then when I work out the sum of those 5 fields are, what I want should be 27M:05S but what shows instead is 1D:03H:05M:00S. As mentioned above, 1D:3H:5M divided by 60 = 27M:5S ... which is the sum I am looking for.
Further examples of this are:
=(SUM(G:G))/60 and
=(AVERAGE(B2:B90)/60) and =MIN(C:C) (this is a direct check so no /60 needed here!).
Note that your "formula" or "calculation" fields (average, total time, etc) MUST have the custom format of MM:SS once you have divided by 60 as Excel's default thinking is in HH:MM (hence this issue). Your data fields where you are entering in your times should need to be changed from "General" or "Number" format to the custom format of HH:MM.
This process is still a little bit cumbersome to use - but it does mean that your data entry is still entered in very easy and is "correctly" displayed on screen as 4:06 (which most people would view as minutes:seconds when under a "Minutes" header). Generally there will only be a couple of fields needing to be used for formulas such as "best time", "average time", "total time" etc when tracking times and they will not usually be changed once the formula is entered so this will be a "one off" process - I use this for my call tracking sheet at work to track "average call", "total call time for day".
Let's say that you want to display the time elapsed between 5pm on Monday and 2:30pm the next day, Tuesday.
In cell A1 (for example), type in the date. In A2, the time. (If you type in 5 pm, including the space, it will display as 5:00 PM. If you want the day of the week to display as well, then in C3 (for example) enter the formula, =A1, then highlight the cell, go into the formatting dropdown menu, select Custom, and type in dddd.
Repeat all this in the row below.
Finally, say you want to display that duration in cell D2. Enter the formula, =(a2+b2)-(a1+b1). If you want this displayed as "22h 30m", select the cell, and in the formatting menu under Custom, type in h"h" m"m".
What I wound up doing was: Put time duration in by hand, e.g. 1 min, 03 sec. Simple but effective. It seems Excel overwrote everything else, even when I used the 'custom format' given in some answers.
Have a list of dates in excel in the format (this comes originally from csv):
23/11/09 07:27:02
23/11/09 08:01:50
23/11/09 08:38:58
23/11/09 09:40:01
What I want to do is count the number of these falling between hour blocks, like 7-8, 8-9, 9-10 etc
Not sure how to get started, but one idea was just to put logic statements comparing the dates between these blocks, then adding the total "trues"
I can't get it to compare properly. When I type it the hour block marks,
e.g. 23/11/09 08:00
excel actually shows that as
23/11/2009 8:00:00 AM
and the compare doesn't work. Well actually it does the opposite of what it should.
that is:
=IF(C5>L1,IF(C5<M1,TRUE,FALSE),FALSE)
C5 being date in top codeblock, L1 and M1 being the hour blocks I manually entered in the second code block.
Has anyone got any ideas?
=hour(a1)=7
will return true if the time of the date/time value in cell A1 is between 7 and 8 (AM) and will otherwise return false.
Excel stores dates as number of days since 1900 or 1904 depending on your setting and the time as a fraction of the days. So 11:59 am 4th of July 1960 is held internally as '22101.4993055556'.
As such you cannot do plain charactrer string comparisons on dates. However ther ar lots of nifty time/date functions available to you.
You probably want :
=IF(HOUR(B1) > 8,IF(HOUR(B1)<12,"YES","NO"),"NO")
You should use Excel functions, like HOUR(), to extract the parts of the times, and apply the logic tests to those extracted values.