Excel integer date-time reference and usage - excel

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.

Related

How can I (easily) format long intervals (over 30 days, but including time components)

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".

Excel calculate the duration between two weekdays time

Hi,
I have this table with me, each record represents one file. My objective is to calculate out the duration for the file to complete.
I stuck at some files are completed within the same day, while some files might complete only after 1 or 2 or 3 days.
Are there any formulas to calculate it out?
Thanks.
You are better off with a single date and time column then use something like the below. Otherwise combine the date and time yourself first
=(TIMEVALUE(B2)-TIMEVALUE(C2)+(TIMEVALUE(B2)<TIMEVALUE(C2)))*24
I think I found a way to achieve that. Solution
First I would apologize for my unclear question. The weekdays are text format, the weekend doesn't count, and the durations are confirmed within one week period.
I actually did the below steps and achieved to my objective.
Convert all the weekdays to numbers, refer to column J and K.
Column L is the variance between column J and K. L=K-J
Then the duration M column put this formula will do.
=IF(L2=0,MOD(I2-G2,1)*24,IF(AND(L2=1,I2>=G2),MOD(I2-G2,1)*24+L2*24,IF(AND(L2=2,I2>=G2),MOD(I2-G2,1)*24+L2*24,IF(AND(L2=3,I2>=G2),MOD(I2-G2,1)*24+L2*24,MOD(I2-G2,1)*24+(L2-1)*24))))

Excel - Turning time into numbers using a formula

I have a time diary spreadsheet that was given to me to record times taken for staff to complete different activities. Column A is the start time, column B is the finish time, where column C is the difference, using the formula B3-A3.
In row 3, this gives me answer of 0:01. Is there a way to convert this to "1" using a formula?
i.e. 0:0X becomes X
or, 0:YX becomes YX?
Thanks
MINUTE() will convert the time to time in minutes.

Time series mock data generation for 16 years of quarterly data in Excel or Matlab

I would like to generate a mock time series quarterly dataset from, say, 2000-2016 for a variable (quarterly credit growth) that averages around a certain value (say, 30%). Can anyone give a suggestion on how to do this in principle?
Edit: what I was implying were the actual data values for each time period, i.e. data with a certain mean and variance.
Found a solution with a code in Matlab, for anyone interested, see below in answers.
Excel approach:
You can make column A your date list. In A1, or A2 or more if you have header rows, you will have to seed your list by providing the first start date. Lets assume you put your seed date in A2. I would then go about adding 3 month to you start date using a formula, and copy down until you have hit your desired date. In order to add the 3 months I would use the following in A3.
=date(year(A2),Month(A2)+3,day(A1)
that will give you the first day of the month every 3 months. If you want the first day of the month every 3 months, set the day to 1 like so:
=date(year(A2),Month(A2)+3,day(A1)
And end of month could be calculated as:
=eomonth(date(year(A2),Month(A2)+3,day(A1)),0)
however I would prefer to do the end of month calculation based on the row you are in so I would do it more like:
=EOMONTH($A$2,(rows($A$2:A3)-1)*3)

COUNTIFS events between dates but also time

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))

Resources