I have to calculate the time until a machine is available again.
The work time is daily from 06:00am until 22:00pm.
If I simply add the time with the hours, the result looks like this.
| Job Duration (hours) | Start | End |
| 18,75 | 21.09.2017 06:00 | 22.09.2017 06:15 |
| 20,14 | 21.09.2017 11:30 | 22.09.2017 07:38 |
This is wrong for me, because the work time is only from 06:00am to 22:00pm.
I would like to achieve the following result:
| Job Duration (hours) | Start | End |
| 18,75 | 21.09.2017 06:00 | 22.09.2017 07:45 |
| 20,14 | 21.09.2017 11:30 | 22.09.2017 15:38 |
Thanks in advance.
Have a look at this example
To get your End time I calculate the actual time the job takes i.e non-working and working hours.
There's 16 hours in the working day (between 6 and 22) and there's 8 non-working hours (between 22 and 6).
=8*(INT(A2/16)+IF(60*((A2-INT(A2/16)*16)+HOUR(B2))+MINUTE(B2)>60*22,1,0))+A2
To break this formula down this:
Calculates the number of non-working periods by doing INT(A2/16)*8 This divides the number of working hours into the job duration
I Then test if the job duration is going to take longer then a day using IF(60*((A6-INT(A6/16)*16)+HOUR(B6))+MINUTE(B6)>60*22 This calculates whether the job would go past 10PM. I compare the two in minutes instead of hours for accuracy. If the job would go past 10PM I add on another non-working period
I then multiple the total number of non-working periods by the number of non-working hours (8)
And finally add the total of non-working hours onto the original job duration
All in all this calculates the amount of non-working hours + working hours to give me the actual time
I then add the actual time to the start time using:
=B2+C2/24
to get my end time.
Then finally, I've combined the formulas to give you your answer in one column
=B2+(8*(INT(A2/16)+IF(60*((A2-INT(A2/16)*16)+HOUR(B2))+MINUTE(B2)>60*22,1,0))+A2)/24
Giving your results:
Related
I'm trying to calculate the time between two dates BUT also whilst taking into account a working hour constraint. I am trying to do this using Excel formulas.
Example follows below, where the working hour constraint would be between 08:00 -> 18:00. I.e only time which follows during these hours should be taken into account.
+---------------+-------------+----------------------+----------------------+
| Start | End | Total Difference | Within Working Hours |
+---------------+-------------+----------------------+----------------------+
| 1/1/19 20:20 | 1/2/19 9:30 | 13 hours, 10 minutes | 1 hour, 30 minutes |
+---------------+-------------+----------------------+----------------------+
The question is how do I calculate the Within Working Hours column?
Thanks!
Use this that counts the days and multiplies that by the 10 hour working days and then adds for hours worked in the window on the work days:
=IF(DATEDIF(A2,B2,"d")>1,NETWORKDAYS.INTL(A2+1,B2-1,1)*10,0)/24+IF(AND(MOD(A2,1)<TIME(18,0,0),WORKDAY.INTL(A2-1,1,1)=INT(A2)),(TIME(18,0,0)-MOD(A2,1)),0)+IF(AND(MOD(B2,1)>TIME(8,0,0),WORKDAY.INTL(B2-1,1,1)=INT(B2)),(MOD(B2,1)-TIME(8,0,0)),0)
Right now we are only excluding weekends, but with NETWORKDAYS.INTL and WORKDAY.INTL one can include a range that will exclude holidays listed.
Then format the cell with a custom number format:
[h] "hour, " mm "minutes"
Let's say i logged in today 9:00 AM and end up 5:00 PM i have to produce 4000 items i know it will exceed the time because my software will stop working at 5 PM so tomorrow when i start working again what would be date and time of completion work
What i did
bring working hour =SUM(B2-A2)
total complete work=ROUND(D2/C2, 2)
If i understood correctly you can use the simple difference of times and correct formatting for the time cells to get the remaining hours
The Formula in cell C5 is simple =C1-C3
The formatting applied to the cells is as below
10.95 hours is equal to 10 hours and 57 (95% of 60) minutes
You can write 10:57:00 instead of 10.95
To convert the time to again a number you can divide the time by 0.041666667 and set the format to general
I want to create cron job for external application to run every second week starting from Thursday
Eg -
9:00 pm,23/5/2019
9:00 pm,6/6/2019
Cron Expression which I can modify
0 0 0 0 0 0 Minute | Hour | Day of Month | Month | Day of Week | Year
I already tried different combinations but not able to receive this functionality
Site I used
https://crontab.guru/
Cron Expression
0 0 0 0 0 0
Minute | Hour | Day of Month | Month | Day of Week | Year
There is no exact method to run the script every two weeks.
For alternatively you can use logic in the external application(script) to decide whether run the script or not. Then you can schedule the Cron to run in every week.
ex: 0 21 * * 4
Above Cron will run in every Thursday of week at 9 PM.
Please refer the below for more info.
https://www.systutorials.com/39652/how-to-run-a-cron-job-every-two-weeks-months-days/
From the script level you can decide whether to run the script or not
I have rankings by country and month, I need to reset the ranking at the beginning of the month 1st day at 00:00.
I have a cron task every 15 minutes checking if with the timezone of the country is day 1 of the month at 0:00 (because some timezones have deviations +x.45 or +x.30 minutes). But, what is the criteria when the country has different timezones?
By example, when is the start time of BlackFriday in one country like USA with different timezones?.
Welcome to the wonderful, horrible world of time! ;-)
In the USA we don't have a unique start time of "Black Friday". We don't even all celebrate New Years at the same moment. Instead we follow our local time zone rules. Not only are there multiple time zone rules covering the single country, even some individual states observe more than one time zone (e.g. Tennessee).
Here is a global map of time zones.
By example, when is the start time of BlackFriday in one country like USA with different timezones?.
Assuming you mean the shopping holiday that follows Thanksgiving Day, which falls this year on Friday, November 23rd 2018:
Time Zone | Local Start Time | UTC Equivalent
----------------------------+------------------------------|------------------------
Guam & Northern Mariana Is. | 2018-11-23T00:00:00+10:00 | 2018-11-22T14:00:00Z
Atlantic (PR, VI) | 2018-11-23T00:00:00-04:00 | 2018-11-23T04:00:00Z
Eastern | 2018-11-23T00:00:00-05:00 | 2018-11-23T05:00:00Z
Central | 2018-11-23T00:00:00-06:00 | 2018-11-23T06:00:00Z
Mountain | 2018-11-23T00:00:00-07:00 | 2018-11-23T07:00:00Z
Pacific | 2018-11-23T00:00:00-08:00 | 2018-11-23T08:00:00Z
Alaska | 2018-11-23T00:00:00-09:00 | 2018-11-23T09:00:00Z
Hawaii | 2018-11-23T00:00:00-10:00 | 2018-11-23T10:00:00Z
American Samoa | 2018-11-23T00:00:00-11:00 | 2018-11-23T11:00:00Z
I have no idea if Black Friday is actually observed in all US territories or not.
As you can see, a single calendar date cannot be mapped to a single range of absolute time, especially when applied to a country with multiple time zones.
BTW, things are even more complicated if you were talking about a date that fell during daylight saving time. For example, much of Arizona doesn't observe DST while the rest of Mountain Time does.
Is it possible to fire a job which will
start on a specific date and time
run every hour from 1:00
from there it should continue till next 3 months for all days
EX:
Start the job on Feb 12 2017, 1:00 AM, runs every hour i.e 2:00AM, 3:00AM
and continue till April 12 2017 for days
Assuming my current date is 10 Nov 2016
Any solution for unix cron is also fine
Below will schedule only on 12th of Feb, Mar and April 2017.
|------------------------------------------------------------------|
| Seconds | Minutes | Hours | DayOfMonth | Month | DayOfWeek | Year|
| | | | | | | |
| 0 | 0 | */1 | 12 | 2-4 | ? | 2017|
|------------------------------------------------------------------|
It can achieved using 3 cron jobs programatically.
First job:- to register the second cron job on the day it should start. Will be triggered(run) only once.
Second job:- to run every hour. Will be triggered multiple times
Third job:- to de-register the second cron job . Will be triggered only once.
Explanantion:-
when the program starts, schedule the first job and also the third job on appropriate dates respectively.
When the first job is ready to run, it will schedule the second job.
When the third job is ready to run, it will remove the second job.