Number of days between two dates for certain year - excel

How do i work out the number of days Fred and John worked during the period between Start and End, during the period of 2018?
I need a count of number of days, for Fred i would expect an output of 89 days, and John would equate to 41. I can work this out manually by doing date subtraction but with the real data there are 1000's of records, is there a way i can do a formula that captures people who worked at the start of 2018, and the end?

Try below formula as per screenshot.
=DATEDIF(IF(AND(B4>=$B$1,B4<=$C$1),B4,$B$1),IF(AND(C4>=$B$1,C4<=$C$1),C4,$C$1),"d")

Related

Excel - SUMIF Function

I made a worksheet covering meal expenses for a set period of time (01-08-2020 until 31-08-2020.)
The company will pay up to 75kr, Monday-Friday.
The list covers expenses 7 days a week, If the amount is greater than 75 on Monday-Friday, I have to pay the extra expenses. (This I have figured out correctly). Saturday and Sunday I have to pay fully.
So my question is, how can I sum this and exclude Saturday and Sunday?
Attempt 1:
I tried this formula (Norwegian excel. Summerhvis = SUMIF. Lørdag = Saturday):
=SUMMERHVIS(B2:B32,"<>lørdag", G2:G32)
It seems to be partly correct however, I miss Sunday, how can I add Sunday to this equation?
Attempt 2:
I used this formula:
=SUMMERHVIS(B2:B32,B2:B6,G2:G32)
It gave the correct answer but the answer was layered in 5 rows. I then summed this in P8.
Where I want the answer is in G32. So in G32 I wrote =p8.
It must be an easier way of doing this?
You can use SUMPRODUCT and the WEEKDAY function:
=SUMPRODUCT((WEEKDAY(A2:A32,3)<5)*G2:G32)
According to the Microsoft function translator, this might be, in Norwegian:
=SUMMERPRODUKT((UKEDAG(A2:A32;3)<5)*G2:G32)
If you really want to use SUMIF and your text days, one way would be (in English):
=SUM(SUMIF(B2:B32,{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday"},G2:G32)),
or, if your weekday days are in b4:b8:
=SUM(SUMIF(B2:B32,$B$4:$B$8,G2:G32))
but I'd advise against it as it would only work in the language of the text days of the week. Also, I note your days of the week don't seem to match up with what the days of the week were in the US. For example, here 1 Aug 2020 was a Saturday, so another possible cause for error (unless I am not understanding the dates correctly).
The above is the same as summing five separate SUMIF equations, each for a desired day of the week.

Calculate difference between two dates to calculate hours and minutes

I would like to get the difference in hours and minutes between two dates with the numbers after the colon in the number of minutes for a SharePoint List on SharePoint 2013. For example:
1st Date: 1/5/2019 1:00 AM
2nd Date: 1/6/2019 2:15 AM
Total: 25:15
=INT((([Date Time Test]-Created)*1440)/60) this gives total of hours. If I remove the 60, that gives total number of minutes or I have tried this: =INT((([Date Time Test]-Created)*24) which also gives the number of hours.
The way I see it, you will need three calculated columns:
one to calculate hours
one to calculate minutes
last one displays the hours & minutes
The big disadvantage of this approach is that all three columns will have to be included in the relevant views.
Second approach (depending on your SP version) - have a workflow calculate hours & minutes and output the result to a single line of text column.
Lastly you can also consider column formatting, depending on SP version again.
You could try to CONCATENATE the hours and minutes, for example:
=CONCATENATE(INT((([SDate]-Created)*1440)/60),":",INT(([SDate]-Created)*1440))

Find first occurrence of X number of missing days in excel

I have a pilot log book organised by date starting in cell A3. First date is in 2006 and it progresses until yesterday. Only dates that have flight hours are logged. So any missing date can be assumed to be a "Day Off".
I need to find a way to find the most recent gap of 5 days off working backwards from TODAY() to a maximum of TODAY()-90 (I am not concerned about gaps more than 90 days from today). I need the formula to return the first date logged after the 5 days off. I cannot use macros.
Example of data assuming start in A3:
2016-11-01
2016-11-03
2016-11-04
**2016-11-05**
**2016-11-14**
2016-11-15
2016-11-16
2016-11-18
2016-11-19
2016-11-21
2016-11-23
Gap is bolded above - Answer I am looking for is 2016-11-14
Thank you very much
With myDates being the range containing the dates, and being less than a full column, sorted ascending as you show, try:
=LOOKUP(2,1/((OFFSET(myDates,1,0)-myDates)>=5),OFFSET(myDates,1,0))
If you want to ignore if the most recent gap was more than 90 days ago, just embed the above in an appropriate IF statement:
=IF((TODAY()-LOOKUP(2,1/((OFFSET(myDates,1,0)-myDates)>=5),OFFSET(myDates,1,0)))>90,"nothing in past 90 days",LOOKUP(2,1/((OFFSET(myDates,1,0)-myDates)>=5),OFFSET(myDates,1,0)))

Excel function to create due dates that land on a business day

I'm stuck creating a formula that will calculate days before the end of the month then adjust to make sure it is a business day. For example: 30 days before 6/30/2015 is 5/31/2015 which is a Sunday. I need that to adjust to the Friday before.
I'm working on finding the due dates of a number of documents that are due a certain number of days before another date. For example: documents are due 30 days before the last day of the month. However, the number of days varies and the due date needs to fall on a business day (Monday-Friday). Sometimes it's 30 days, sometimes it's 60 days, sometimes it's 30 calendar days + 5 business days, etc.
I've been able to calculate 30 days + 5 business days with the following formula:
=workday(start_date-30,-5)
Any ideas how to adjust this so that I can just have the due date be 30 calendar days before a certain date but also always be a business day?
Using WORKDAY you can use a formula like this:
=WORKDAY(A1+B1+1,-1)
where A1 is your start date and B1 the number of days to add.
You probably need to write a macro function or maybe some nested IF statements in your cell's formula.
Take a look at http://www.mrexcel.com/forum/excel-questions/481558-round-date-nearest-workday.html
That solution moves forward to the nearest workday, but the principle is sound: just subtract instead of add.

Tallying dates and times in excel

Is there an easy way to tally a column formatted as follows: "5/24/2013 5:48:00 PM"
What I want to do is have it tally by day of week and an hour time block, the end result I'm looking for would look like the following:
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1:00-2:00AM 10 2 8 7 3 12 15
2:00-3:00AM 5 4 7 7 9 11 18
et cetera. This is an extremely large data set so avoiding doing this by hand would be amazing. I apologize if this is a terrible question, I tried searching though other people's questions to no avail.
Not knowing the details, I would try to use a PivotTable.
There is the ability to group by dates; see this page for details (including a fancy animation).
Some additional searching should turn up a lot of resources on PivotTables; they are very powerful.
I'd assign a number to the rows/columns and then use sumif().
I would create add two columns: one with =Hour(A2), other with =WeekDay(A2) (example for row 2, assuming dates are on column A).
Then, use PivotTable on all data.
Regard formats: WeekDay must be formated as ddd or dddd and Hour as numeric.

Resources