Calculate Days in Month Book is checked out

Will85

Board Regular
Joined
Apr 26, 2012
Messages
240
Office Version
  1. 365
Platform
  1. Windows
Sheet 1 column A stores Check-out dates, column B stores Return Dates
If the last entry in Column A does not have a corresponding entry in Column B, the book is still checked out

A book can be checked in and out an unknown number of times. A book cannot be checked out and then returned (or vice versa) on the same day, and both the day a book is checked out and the day it is returned are included in the days the book was checked out.

Sheet 2 A1:L1 has the 12 months going across Jan - Dec of a particular year, say 2019

Sheet 2 A2:L2 needs to sum the number of days in that month that the book was checked out, based on the check-in and out days.

Sheet 3 A1 has the last day of a specific month for the report, as an example 6/30/2019. So my report would be as of 6/30/2019 and months Jan through June would calculate on Sheet 2. (If a book has no return date, then the max number of days checked out would be from the check out date, up to 6/30/2019). The cell in Sheet 3 A1 will always be the last day of the month the report is for.

For example, if sheet 1 had three entries A1= 12/15/2018 B1= 2/28/2019 and A2= 5/29/2019, then sheet 2 A2 = 31, B2 = 28, C2 = 0, D2 = 0, E2 = 3, F2 = 30, and zero for the rest of the months since the report is as of June.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I use custom function: countDays(a2,a3)

Code:
function countDays(pvStartDate, pvEndDate)
 countDays = DateDiff("d",pvStartDate,  pvEndDate
end function
 
Upvote 0
I use custom function: countDays(a2,a3)

Code:
function countDays(pvStartDate, pvEndDate)
countDays = DateDiff("d",pvStartDate,  pvEndDate
end function

I wanted to do this via built in excel formula in each month.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top