I have a excel data with range date to be calculated
Created Time Completed Time Duration
07-Jan-2016 15:48 11-Jan-2016 15:39 3 Days 23:51
12-Jul-2016 11:28 28-Jul-2016 17:13 16 Days 05:45
12-Jul-2016 11:30 08-Nov-2016 10:40 118 Days 23:10
09/08/2016 14:45 31/08/2016 17:03 22 Days 02:18
09/08/2016 14:46 31/08/2016 17:04 22 Days 02:18
I have this formula below and the result on "duration" coloumn.
CONCATENATE(TEXT(FLOOR(K4-J4;1);"#");" Days "; TEXT(K4-J4;"hH:mm"))
I want to convert that counted days into months..
So it will be 3 Months, 28 Days 23 Hours and 10 Minutes for (118 Days 23:10)
Need your help to solve my problem :)
UNTESTED Assuming Created Time is in A1, please try in C2 and copied down to suit:
=INT((B2-A2)/30)& " Months "&INT(MOD((B2-A2),30))&" Days "&INT(24*(MOD((B2-A2),30)-INT(MOD((B2-A2),30))))&" Hours and "&MINUTE(B2-A2)&" Minutes"
If the first Created Time is in A2 and the first Completed Time is in B2 then pop the following formula in C2 =IF(DAYS(B2,A2)>0,CONCATENATE(IF(DATEDIF(A2,B2,"y")=0,"",DATEDIF(A2,B2,"y")),IF(DATEDIF(A2,B2,"y")=0,"", " year"),IF(DATEDIF(A2,B2,"y")>1,"s",""),IF(AND(DATEDIF(A2,B2,"y")>0,DATEDIF(A2,B2,"ym")>0),IF(IF(AND(DATEDIF(A2,B2,"md")>0,OR(DATEDIF(A2,B2,"y")>0,DATEDIF(A2,B2,"ym")>0))," and ","")=""," and ",", "),""),IF(DATEDIF(A2,B2,"ym")=0,"",DATEDIF(A2,B2,"ym")),IF(DATEDIF(A2,B2,"ym")=0,"", " month"),IF(DATEDIF(A2,B2,"ym")>1,"s",""),IF(AND(DATEDIF(A2,B2,"md")>0,OR(DATEDIF(A2,B2,"y")>0,DATEDIF(A2,B2,"ym")>0))," and ",""),IF(DATEDIF(A2,B2,"md")=0,"",DATEDIF(A2,B2,"md")),IF(DATEDIF(A2,B2,"md")=0,"", " day"),IF(DATEDIF(A2,B2,"md")>1,"s","")),"") & " " & HOUR(B2-A2) & " hours " & MINUTE(B2-A2) & " minutes"
Related
I am currently working on grouping/aggregating data based on date range for a weekly plot.
Below is how my dataframe looks like for Daily data:
daily_dates
registered
attended
02/10/2022
0
0
02/09/2022
0
0
02/08/2022
1
0
02/07/2022
1
0
02/06/2022
20
06
02/05/2022
05
03
02/04/2022
15
12
02/03/2022
10
08
02/02/2022
10
05
The first day of the week I'd want is Sunday.
My current code to perform weekly group is:
weekly_df = weekly_df.resample('w').sum().reset_index()
The output I am desiring is:
weekly_dates
registered
attended
02/06/2022
22
06
01/30/2022
40
28
A bit of explanation about desired output - the reason for 02/06/2022 & 01/30/2022 is that both these dates are start date of that respective week which is a sunday. And for the week of 01/30/2022 only 02/05/2022|05|03, 02/04/2022, 02/03/2022, 02/02/2022 dates are considered as those are the one's in the daily dataframe.
My current implementation follows the instructions provided here.
I am looking for any suggestion to achieve my Desired Output
Try:
df.resample('W-SUN', label='left', closed='left').sum().reset_index()
Output:
daily_dates registered attended
0 2022-01-30 40 28
1 2022-02-06 22 6
I have the following table below. I will be referencing a specific number based on other extraneous information. Lets say the specific number is 30. I first need to count 30 numbers down my September list then move to October then November until count has reached 30. Then I need to count all the missing values until the next value would reach the 30th count from the previous task. So for this example the 30th number would be November 19th. The count of the missing should be 55, November 15th (if I counted that right). That value would then be stored in a cell.
I obtained the missed days with the following formula: =IFERROR(SMALL(IF(ISERROR(MATCH(ROW(L$1:INDEX(L:L,N$2)),M$2:INDEX(M:M,COUNT(M:M)+ROW(M$1)),0)),ROW(L$1:INDEX(L:L,N$2))),ROW()-ROW(L$1)),"") (see table 2 for column reference)
The max column value will be blank if there is no data in the month column, therefore the missed column will also have not data. I set that up with the following formula:
=IF(COUNTA(M:M)>1,31,"") (see table 2 for column reference)
Table 1
September max missed October max missed November max missed
1 30 4 1 31 2 2 30 1
2 6 3 6 7 3
3 7 4 7 9 4
5 11 5 8 10 5
8 12 12 9 11 6
9 13 15 10 16 8
10 14 20 11 17 12
15 16 28 13 18 13
22 17 30 14 19 14
23 18 31 16 20 15
24 19 17 22 21
25 20 18 27 23
29 21 19 28 24
26 21 25
27 22 26
28 23 29
30 24 30
25
26
27
29
Table 2
L M N O
(blank) September max missed
I have an idea of how I would write this, but do not know the syntax:
x = Select(Range("G8").Value)
'value that holds specific value (30 for above example)
If x < 31 Then
'30 days in September
y = Count(M2:M32) Until = x
'values in September
z = Count(O2:O32) Until = value of y - 1
'What if the last value is the 30th of September, how would you stop on August 31st?
Range("A1").Value = z
'value of z is stored in cell A1
Elseif x < 62 Then
'61 days in September and October
y2 = Count(M2:M32) & Count(Q2:Q32) Until = x
'Values in September and October
z2 = Count(R2:R32) & (S2:S32) Until =value of -1
'Again, if the last value is the 31st of October how would you stop on September 30th?
Range("A1").Value = z
'Value of z is stored in cell A1
Elseif
'continue for each month (12 times)
End If
There are a couple of things that could cause some problems here with my suggestions (that I just thought of). How would I dictate my starting month? Lets say I wanted to reference a specific cell and that cell contains the number 4. So I would want to start in April, even if I had data in March. Another way of thinking about this is March is in year 2019 and April is in 2018. So then how could I could I get the code to jump from say December back to January? Say column Z is December and column A is January. I wouldn't necessarily want my code to only read left to right. It would need to start in reference to another cell and then jump back to the start if the year changes.
I apologies for the lengthiness, but that's my best effort in explaining. Let me know if you have any questions or if I can provide anyone with more example, pictures, etc.
I think you should reorganize your data table to something like this:
Day Status
01.09.2018 ok
02.09.2018 ok
03.09.2018 ok
04.09.2018 missed
05.09.2018 ok
06.09.2018 missed
07.09.2018 missed
08.09.2018 ok
09.09.2018 ok
10.09.2018 ok
11.09.2018 missed
12.09.2018 missed
13.09.2018 missed
14.09.2018 missed
15.09.2018 ok
16.09.2018 missed
17.09.2018 missed
18.09.2018 missed
19.09.2018 missed
20.09.2018 missed
21.09.2018 missed
22.09.2018 ok
23.09.2018 ok
24.09.2018 ok
25.09.2018 ok
26.09.2018 missed
27.09.2018 missed
28.09.2018 missed
29.09.2018 ok
30.09.2018 missed
01.10.2018 ok
02.10.2018 ok
03.10.2018 ok
04.10.2018 ok
05.10.2018 ok
06.10.2018 ok
07.10.2018 ok
08.10.2018 ok
09.10.2018 ok
10.10.2018 ok
11.10.2018 ok
12.10.2018 ok
13.10.2018 ok
14.10.2018 ok
15.10.2018 ok
16.10.2018 ok
17.10.2018 ok
18.10.2018 ok
19.10.2018 ok
20.10.2018 ok
21.10.2018 ok
22.10.2018 ok
23.10.2018 ok
24.10.2018 ok
25.10.2018 ok
26.10.2018 ok
27.10.2018 ok
28.10.2018 ok
29.10.2018 ok
30.10.2018 ok
31.10.2018 missed
After that, you could easily manage your counts, find anything you want via filtering, specifying date start and so on
I am on Linux and I am trying to add a certain number of days, hours and minutes to a specified calendar date using the date tool:
For example:
$ date -d "2013-01-01 + 305 days 12 hours 30 minutes" +"%Y%m%d%0k%M%S"
20131102123000
Splitting the result up so it's easier for us to read:
2013-11-02 12:30:00
This appears to be working correctly. However, when I add 306 days instead of 305:
$ date -d "2013-01-01 + 306 days 12 hours 30 minutes" +"%Y%m%d%0k%M%S"
20131103113000
Split:
2013-11-03 11:30:00
Notice how the hour now shows 11 instead of 12! But I told it to add 12 hours... Let me increment the day one more time:
$ date -d "2013-01-01 + 307 days 12 hours 30 minutes" +"%Y%m%d%0k%M%S"
20131104123000
And split the result again:
2013-11-04 12:30:00
Now the hour goes back to what I expected. I have tested this using date versions 8.12 and 8.4, the same result happens on both. What am I doing wrong?
I was trying to add from a UTC date, but I did not specify this to the tool. This is the solution:
date --utc -d "2013-01-01 + 307 days 12 hours 30 minutes" +"%Y%m%d%0k%M%S"
Because UTC does not observe DST, there will be no shifts in the hour.
I'm trying to understand length of an outage that occurs within time range.
In once cell I have the support period: Level 1 Monday-Saturday 0800-1800
In two other cells I have the start time and end time of the outage
Example:
Outage Start: Wednesday, 24 August 2016 16:47
Outage End: Monday, 29 August 2016 10:15
Result should return: 33:28 hours
Workings:
Wednesday, 24 August 2016 16:47 - 18:00 = + 01:13
Thursday , 25 August 2016 08:00 - 18:00 = + 10:00
Friday , 26 August 2016 08:00 - 18:00 = + 10:00
Saturday , 27 August 2016 08:00 - 18:00 = + 10:00
Monday , 29 August 2016 08:00 - 10:15 = + 02:15
Any advice appreciated!
Updated
Please check the above image, I hope you want something similar to this.
Enter the following formula in the column C2
=INT(IF(DAYS(B2,A2)=0,IF(TEXT(A2,"ddd")="Sun",0,ROUND((B2-A2)/(1/24/60),0)
),IF(DAYS(B2,A2)=1,IF(TEXT(A2,"ddd")="Sun",0,(DATE(YEAR(A2),MONTH(A2),DAY(A2))+1/24*18)-A2
)/(1/24/60) +
IF(TEXT(B2,"ddd")="Sun",0,B2-(DATE(YEAR(B2),MONTH(B2),DAY(B2))+1/24*8)
)/(1/24/60),IF(TEXT(A2,"ddd")="Sun",0,(DATE(YEAR(A2),MONTH(A2),DAY(A2))+1/24*18)-A2
)/(1/24/60) +
IF(TEXT(B2,"ddd")="Sun",0,B2-(DATE(YEAR(B2),MONTH(B2),DAY(B2))+1/24*8)
)/(1/24/60) +
(IF(DAYS((DATE(YEAR(B2-1),MONTH(B2-1),DAY(B2-1))),A2)<0,0,DAYS((DATE(YEAR(B2-1),MONTH(B2-1),DAY(B2-1))),A2))-
INT(((DATE(YEAR(B2-1),MONTH(B2-1),DAY(B2-1)))-(DATE(YEAR(A2),MONTH(A2),DAY(A2)) + MOD(DATE(YEAR(A2),MONTH(A2),DAY(A2)),7)))/7+1)) * 10 * 60
)
))
Enter the following formula in the cell D2
=INT(C2/60) &":" & INT(MOD(C2,60)+0.5)
Then copy the C2 and D2 to all the cells that you want, it will give the outage value that you are looking for.
For example if cell A2 contains the Outage Start date Wednesday, 24 August 2016 16:47 and cell B2 contains the Outage End date Monday, 29 August 2016 10:15, then you can use the following:
=DAY(B2-A2)
This will return 4 days.
=HOUR(B2-A2)
Will return 17 hours
=MINUTE(B2-A2)
Will return 28 minutes.
Then you could use the following:
="The outage lasted for "& DAY(B2-A2) & " days, " & HOUR(B2-A2) & " hours, and " & MINUTE(B2-A2) & " minutes."
To produce this:
The outage lasted for 4 days, 17 hours, and 28 minutes.
I have data as below:
amos 50 10/16/2012 10:13
amri 50 1/9/2013 9:31
andi 10 3/11/2008 10:35
andik 10 12/6/2012 16:58
anggoro 50 9/13/2012 16:14
ari_prabowo 50 11/26/2012 10:30
astra_permana 10 8/2/2010 17:40
atang 10 1/16/2009 14:39
I want to counting how many times such like year of "2008", "2009", "2010", "2012", "2013" occurred.
Thanks for re-formatting your data.
I would add a helper column to calculate the year
=YEAR($A$1)
Then you can use a countif on that column
=COUNTIF($B$1:$B$10,2008)
Otherwise you could use a sumproduct (Excel 2003)
=SUMPRODUCT(($A$1:$A$10>=DATE(2008,1,1))*($A$1:$A$10<DATE(2009,1,1)))
Or countifs (excel 2007 +)
=COUNTIFS($A$1:$A$10,">=1/1/08",$A$1:$A$10,"<1/1/09")