Find length of time within range - excel

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.

Related

How take from string the words I need?

I have many strings like these.
Roliffe (Day) - Thursday, 15 June 2019
Tadcorp Pk Munangle (Day) - Tuesday, 10 July 2019
Gecester Park (Night) - Friday, 26 June 2019
I need to take names for example Roliffe, Tadcorp Pk Munangle, Gecester Park
And dates 15 June 2019, 10 July 2019, 26 June 2019
How can I make it?
I would use regular expressions like this:
import re
string = """Roliffe (Day) - Thursday, 15 June 2019
Tadcorp Pk Munangle (Day) - Tuesday, 10 July 2019
Gecester Park (Night) - Friday, 26 June 2019"""
places = re.findall(r'([\w ]*) \(.*\)', string)
dates = re.findall(r'\d{2} \w* \d{4}', string)
print(', '.join(places))
print(', '.join(dates))
Output
Roliffe, Tadcorp Pk Munangle, Gecester Park
15 June 2019, 10 July 2019, 26 June 2019
If the data follows the same pattern.
This will not be an efficient one but will work.
s = 'Roliffe (Day) - Thursday, 15 June 2019';
firstSplit = s.split('(');
name = firstSplit[0].trim();
date = firstSplit[1].split(',')[1].trim();

Cron expression that runs for every 2 years

I need to run a particular script starting from Jan 1st of 2019 at 12 AM and next it should run on Jan 1st 2021 at 12 AM, then on Jan 1st 2023 at 12 AM and soon.
You can create and/or check the cron expression format with http://www.cronmaker.com/
0 0 0 1 1 ? 2019/2
This should work. It will run the task on
1. Tuesday, January 1, 2019 12:00 AM
2. Friday, January 1, 2021 12:00 AM
3. Sunday, January 1, 2023 12:00 AM
4. Wednesday, January 1, 2025 12:00 AM
5. Friday, January 1, 2027 12:00 AM

Excel, Count Hour and Minute to Days More that 1 month

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"

Get specific day of week of the upcoming Canada day on Linux

How to use cal command to add the calendar of next July to the end of the file, for example, myfile, and what day of the week the upcoming Canada Day fall on?
So far I just have this command:
cal July 2017 >> myfile
I feel like I am not doing it correct and I don't know which command to use, to find the day of the week for specific date.
Use this command:
cal 7 2017 >> file
The output is:
July 2017
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
You can find out day of week of a particular day with the GNU date command:
date -d"2017-07-01" # what day of week is Canada Day this year?
=> Sat Jul 1 00:00:00 UTC 2017
If you just want the week day, then:
date -d"2017-07-01" +%A
=> Saturday
You can check more about these commands with man cal or man date.
On a Mac, you could do this:
date -j -vJulm -v1d -v2017y +%A
See more on this post: date command on Mac OS

Excel:Next year period

How to get next year period based on current month and year, for example:
Jan 2014 - Dec 2014
Feb 2014 - Jan 2015
Mar 2014 - Feb 2015
Apr 2014 - Mar 2015
May 2014 - Apr 2015
Jun 2014 - May 2015
Jul 2014 - Jun 2015
Aug 2014 - Jul 2015
Sep 2014 - Aug 2015
Oct 2014 - Sep 2015
Nov 2014 - Oct 2015
Dec 2014 - Nov 2015
Next period
Jan 2015 - Dec 2015
Feb 2015 - Jan 2016
etc.
I have tried with the following formula:
=UPPER(TEXT(NOW();"MMM")) &" "& TEXT(NOW();"YY")-1
It works fine for Jan 2014 but can't figure out how to get Dec 2014; Feb 2014 - Jan 2015 and so on?
I think you need the EOMonth formula.
=EOMONTH(NOW(),-13) +1 and =EOMONTH(NOW(),-2) +1 should give give you JAN 2014 to DEC 2014
from the MS Excel documentation
Microsoft Excel stores dates as sequential serial numbers so they can
be used in calculations. By default, January 1, 1900 is serial number
1, and January 1, 2008 is serial number 39448 because it is 39,448
days after January 1, 1900.
To get the text formatting you are after, I would suggest that you stick with formatting the cell/column as #Makyen has suggested. Having said that this is the formula that you can use to format the text.
=UPPER(TEXT(EOMONTH(NOW(),-13) +1, "MMM YY"))
Assuming that the date (as a date serial number) for which you desire to find the year period is in cell A1, the following should provide the next year period starting from that day:
=EOMONTH(A1,11) +DAY(A1) -1
Examples:
Input Output
1/18/2014 1/17/2015
2/18/2014 2/17/2015
3/18/2014 3/17/2015
4/18/2014 4/17/2015
5/18/2014 5/17/2015
6/18/2014 6/17/2015
7/18/2014 7/17/2015
8/18/2014 8/17/2015
9/18/2014 9/17/2015
10/18/2014 10/17/2015
11/18/2014 11/17/2015
12/18/2014 12/17/2015
1/18/2015 1/17/2016
2/18/2015 2/17/2016
3/18/2015 3/17/2016
4/18/2015 4/17/2016
5/18/2015 5/17/2016
6/18/2015 6/17/2016
7/18/2015 7/17/2016
8/18/2015 8/17/2016
9/18/2015 9/17/2016
10/18/2015 10/17/2016
11/18/2015 11/17/2016
12/18/2015 12/17/2016
1/18/2016 1/17/2017
If you want the year period to start from the current day:
=EOMONTH(NOW(),11) + DAY(NOW()) -1
If you want the year period to start from the first day of the current month:
=EOMONTH(EOMONTH(NOW(),-1) + 1,11)
or
=EOMONTH(NOW() - DAY(NOW()) + 1,11)
The EOMONTH() function:
EOMONTH(start_date,months)
Returns the serial number for the last day of the month that is the
indicated number of months before or after start_date. Use EOMONTH to
calculate maturity dates or due dates that fall on the last day of the
month.
If this function is not available, and returns the #NAME? error,
install and load the Analysis ToolPak add-in.

Resources