Length of stay in a financial year

queysoft

New Member
Joined
Aug 3, 2021
Messages
49
Office Version
  1. 2016
Platform
  1. Windows
Hello. I have been looking at a a formula that can automatically calculate something i do manually. However I cannot find a one formula fits all solution. Its to do with the length of stay of 2 different types of animals in a financial year (starting April 1). Column A has the animal type and column B the arrival date. Column C has the departure date when they leave. Line 2 shows animal 1 arrived February but left on April 15, so the length of stay is 15 days this financial year. Line 3 is 10 days and for line 4/5/6 its 26 days, 11 and then 6.

Can there be a formula that would populate column D automatically given those conditions?

Thanks for any help. It will save me time everytime the boss asks!!
 

Attachments

  • animalsLOS.JPG
    animalsLOS.JPG
    37.8 KB · Views: 6

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
For the future, consider this for your sample data provision so helpers do have to manually type sample data. :)
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Try this in D2 and copy down
Excel Formula:
=IF(C2="",TODAY(),C2)-MAX(B2,DATEVALUE("1 April"))+1
 
Upvote 0
Solution
how about?

Book1
ABCD
1
2101/02/202215/04/202215
3201/03/202210/04/202210
4101/04/202215/04/202215
5201/04/202226
6115/04/202212
7220/04/20227
Sheet1
Cell Formulas
RangeFormula
D2:D7D2=IF(ISBLANK(C2),TODAY(),C2)-MAX(B2,DATE(2022,4,1))+1
 
Upvote 0
Hello and thank you for your prompt reply. Yes, I was aware of the add in (and that would be my choice do do so) however I am on the works laptop right now and adding that in has been restricted. However I note your comment. I did not know about the 'test here' so that's good knowledge.

As for the solution, yes it works perfectly - thank you for that!

Many thanks and will endeavour to go down the add in route in future!!

Mark.
 
Upvote 0
how about?

Book1
ABCD
1
2101/02/202215/04/202215
3201/03/202210/04/202210
4101/04/202215/04/202215
5201/04/202226
6115/04/202212
7220/04/20227
Sheet1
Cell Formulas
RangeFormula
D2:D7D2=IF(ISBLANK(C2),TODAY(),C2)-MAX(B2,DATE(2022,4,1))+1
Hi - Yes, that works too!!

Many thanks, I need to get to grips with the more advance "basic" formula!!
 
Upvote 0
As for the solution, yes it works perfectly - thank you for that!
You're welcome. Thanks for the follow-up.

however I am on the works laptop right now and adding that in has been restricted.
As a second choice, you can just copy/paste from your worksheet like below. At least we can copy something from that. :)

Arrival DateDeparture dateLOS
01-Feb​
15-Apr​
15​
01-Mar​
10-Apr​
10​
01-Apr​
15-Apr​
15​
01-Apr​
26​
15-Apr​
12​
20-Apr​
7​
 
Upvote 0

Forum statistics

Threads
1,215,693
Messages
6,126,248
Members
449,304
Latest member
hagia_sofia

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