entry date exit date
8-10-2009 10-5-09
I need to know the difference between the exit day and the current month
10Q in advance
entry date exit date
8-10-2009 10-5-09
I need to know the difference between the exit day and the current month
10Q in advance
Last edited by galarza; 10-25-2009 at 04:56 PM.
In your example above, what do you expect the answer to be?
The Exit Day and the current month are the same, so it's unclear.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
entry date exit days number of days
9/21/2009 10/1/09
9/22/2009 10/2/09
9/28/2009 10/6/09
10/2/2009 10/9/09
10/2/2009 10/2/09
10/3/2009 10/3/09
10/5/2009 10/8/09
10/5/2009
10/5/2009
10/5/2009
Apologize for not been clear.
I need to know how many days this person remained in the month of October
This formula is a bit of a trick. You put the month start date in a fixed cell (in this case C1), then use this SUMPRODUCT() formula:
In C2 use:Please Login or Register to view this content.
=SUMPRODUCT((ROW(INDIRECT($A2&":"&$B2))>=$C$1) * (ROW(INDIRECT($A2&":"&$B2))<DATE(YEAR(C$1),MONTH(C$1)+1,1)))
...and copy it down.
When adding/subtracting dates, people disagree about what the answer should be, some think the dates should be inclusive of the start date, other say no. That's why I asked you for some sample answers. Anyway, you may decide you need to subtract 1 from the answers. Up to you.
JB, why the need for (Volatile) SUMPRODUCT ?
With month specified in C1
=MIN(DATE(YEAR(C$1),MONTH(C$1)+1,0),B2+1)-MAX(C$1-DAY(C$1)+1,A2)
copied down
if you know categorically that C1 is always first of month you can remove the -DAY+1 check.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
numb of
start end nights
9/22/2009 10/2/09 1
9/28/2009 10/6/09 5
10/2/2009 10/9/09 7
10/2/2009 10/2/09 0
10/3/2009 10/3/09 0
10/5/2009 10/8/09 3
9/25/2009 10/6/09 5
I should get this results. We count just nights, just like in a hotel billing, 10Q for you patience
As I said, then, my original formula... then -1.
=SUMPRODUCT((ROW(INDIRECT($A2&":"&$B2))>=$C$1) * (ROW(INDIRECT($A2&":"&$B2))<DATE(YEAR(C$1),MONTH(C$1)+1,1))) - 1
Or Don's.... -1:
=MIN(DATE(YEAR(C$1),MONTH(C$1)+1,0),B2+1)-MAX(C$1-DAY(C$1)+1,A2) - 1
===========
If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].
(Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)
Thanks you guys are great, 10Q as always
If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].
(Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)
That won't give the correct results in all circumstances, try making B2 31st October......
This should work better
=MIN(DATE(YEAR(C$1),MONTH(C$1)+1,1),B2)-MAX(C$1-DAY(C$1)+1,A2)
although you might want to adjust that to take account of end dates that are eralier than the current month, i.e.
=MAX(0,MIN(DATE(YEAR(C$1),MONTH(C$1)+1,1),B2)-MAX(C$1-DAY(C$1)+1,A2))
Ooops one more thing, how can I get rid of the negative numbers??, since I need to run a total at the end of the sheet??
12
27
-40087
-40087
-40087
1
-40087
7
1
0
15
-40087
I tried the =min and =max formulas and I get 31 when I fill them down.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks