• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calculating Dates in a Range

vanguter

New Member
I'm trying to come up with a formula to calculate # of days passed from a range of cells... Example: Cells D125:AD125 contain 2 dates; 11/20/2012 (in D125) and 1/3/2013 (in M125). I want to automatically calculate the age of each and count them to display how many are <30 days, how many are 30-59 days, how many are 60-89 days, etc. (I do have a column for each age range; so column AF is <30, AG is 30-59, etc.) I've tried COUNT, COUNTIF, DAYS360, etc... Can't seem to get it right. Any suggestions would be greatly appreicated! Thanks!
 
Assumptions:

Date ranges/groupings are in 30 day groups.

Text or nothing is in cell AE2.

The dates in future have age < 0 whereas dates in the past have ages > 0.


formula in AF2:

=COUNTIF($D$125:$AD$125,">"&TODAY()-30*COLUMN(A$1))-SUM($AE2:AE2)
 
may not the be best solution...but it works


This is assuming the following layout:

A1=first date

B1=second date

C1=If <30 Column

D1=If >=30 and <59 Column

E1:If >=60 and <89 Column

**Additional columns could be added as needed.


Formulas:

A2= none

B2= none

C2= =IF(B2-A2<30,B2-A2,"")

D2= =IF(AND(B2-A2>=30,B2-A2<60),B2-A2,"")

E2= =IF(AND(B2-A2>=60,B2-A2<90),B2-A2,"")


what this will do is it will look at the difference between the dates in b1 & a1.

-- if the Difference is <30 the value will show up in Col.C. (if it is not, nothing will be displayed)

-- If the difference is equal to or greater than 30 and less than 60, the value will show up in Col.D. (if it is not, nothing will be displayed)

-- the same happens in Col.E.


does this work for what you are needing?
 
Luke, what does COLUMN(A$1)represent in your formula? When I use that formula as is... the result is "1/1"..
 
I've gotten this to work in a different sheet using a cell for TODAY() and a cell for calculations of each date, but in that case, I'm only counting one record at a time. In this new sheet, i'm trying to count the number of xx in a range.
 
Correction to my response to Luke... the cell was displaying as a date. Fixed that/changed to Number and it now shows 1 ;) What about the 30-60, 60-90, etc. Sorry, I'm pretty new at intricate formulas.


My other sheet is laid out as follows:

Cell A1: TODAY()

Cell A2: 11/20/2012

Cell A3: =$A$1-A2

Cell A4: =COUNTIF(A3,"<30")

Cell A5: =IF(AND(30<A3,A3<60),1,0)

Cell A6: =IF(AND(60<A3,A3<90),1,0)

Cell A7: =COUNTIF(A3,">90")


So that works great, but if I want to count multiple cells/dates, that's where my challenge is...
 
Hi Vanguter ,


Can you download the following file and see if this is what you want ?


I have copied Luke's formula.


http://speedy.sh/BXn3z/Vanguter-Example.xlsx


Narayan
 
The COLUMN function is there to serve as a counter, starting an increment count at 1. So, it first evaluates to

[pre]
Code:
COLUMN(A1)*30
1*30
30
When you copy the cell to the right, it becomes

[code]COLUMN(B1)*30
2*30
60
[/pre]
So, each cell, in order, finds out how manys cells are older than 30 days, 60 days, 90 days, etc. The -SUM(...)[/code] bit is to subtract the portion that we've already counted (since we want 30-59, not 0-59).
 
Hi Luke,

Not sure if this matters to the OP, but if there are dates greater than TODAY(), the first value returned by the COUNTIF formula would include a count of those future dates.


I took a slightly different direction with the calculation, to allow the user to specify the actual age range of interest:


Assuming that the age is indicated as below (in cells A1:C5):

[pre]
Code:
Low	High	Count
0	30	3
31	60	1
61	90	1
91	600	2
The following formula in cell C2, would indicate the count corresponding to the age for dates between A2 and B2:

=INDEX(FREQUENCY(N(IF(ISNUMBER(DateData),(DateToCheck-DateData))), CHOOSE({1,2}, A2,B2)), 2)

entered with Ctrl + Shift + Enter


and copied down to C3:C5


Here "DataData" refers to the range of cells with dates, and "DateToCheck" refers to "=TODAY()", etc.


My sample test data was as follows:

12/15/2012	blank	12/28/2012	blank	2/5/2013	3/15/2013
10/15/2012	11/15/2012	2/2/2012	3/15/2012	blank	1/3/2013
[/pre]
and DateToCheck was set to "1/8/2013"


Cheers,

Sajan.


Edit: You can remove the N() from the above formula, since it is not needed.
 
@Sajan

Hi!

A silly doubt. It seems as this year I'm more curious than before... I've sometimes read "the OP..." and as my English is neither native nor slang/local, would you -or anybody else- please tell me what does OP mean? Thanks in advance.

Regards!
 
Good evening my friend


I can say that as a person who has answered over 3000 times your are with out doubt an ORIGINAL POSTER
 
@b(ut)ob(ut)hc

Hi, my friend!

Didn't I say it was a silly doubt? Ha ha ha...

Thanks a lot for enlighten the obscurity of my ignorance with a beam of wisdom.

Regards!

PS: I was wrong, I should've said it was a very very very silly doubt.
 
Back
Top