+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Date ranges withing date ranges

  1. #1
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Question Date ranges withing date ranges

    Hi Guys,

    I'm Stuck ....

    I have a date range with start date and end date
    INFO!D5 = start date
    INFO!D6 = end date

    I need to find out in this range ( start and end) how many days fall :

    1. Days Before 01/03/11
    2. Days Between 01/03/11 + 01/06/11
    3. Days after 01/06/11

    i have the before and after dates working but its where have dates running between i get stuck

    if i have a date that run like
    26/02/2011
    27/03/2011

    I need to show - 2 before 01/03/11 and 27 after 01/03/11

    or if a date runs like
    26/05/2011
    27/06/2011

    I need to show - 5 between 01/03/11 + 01/06/11 and 27 after 01/06/11

    Any ideas ?

    Thanks,
    Saz

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Date ranges withing date ranges

    Assuming you used COUNTIF for before and after, then for between use COUNTIFS

    e.g.

    =COUNTIFS(range,">="&DATE(2011,3,1),range,"<="&DATE(2011,6,1))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Date ranges withing date ranges

    I havent used COUNTIFS instead using something way more time consuming

    1 ... Days Before 01/03/11

    =IF(AND(Info!D5<DATE(2011,3,1),Info!D6<DATE(2011,3,1)),(Info!D6-Info!D5),IF(AND(Info!D5<DATE(2011,3,1),Info!D6>DATE(2011,3,1)),DATE(2011,3,1)-Info!D5,0))


    2 ....Days After 01/06/11

    =IF(AND(Info!D5>DATE(2011,6,1),Info!D6>DATE(2011,6,1)),(Info!D6-Info!D5),IF(AND(Info!D5<DATE(2011,6,1),Info!D6>DATE(2011,6,1)),Info!D6-DATE(2011,6,1),0))


    3 ... I think i have the between 01/03/11 and 01/06/11 with overlapping dates working my way too

    =IF(AND(Info!D5>DATE(2011,3,1),Info!D6<DATE(2011,6,1)),(Info!D6-Info!D5),IF(AND(Info!D5<=DATE(2011,3,1),Info!D6>=DATE(2011,3,1)),Info!D6-DATE(2011,3,1),IF(AND(Info!D5>DATE(2011,3,1),Info!D6>DATE(2011,6,1)),DATE(2011,6,1)-Info!D5+1,0)))


    But your way looks to be way more efficient, would that way work if i had overlapping dates before and after 01/03/11 ( or 01/06/11) ?

    Thanks,
    Saz

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Date ranges withing date ranges

    My formula looks at a range and counts number of matches... since you are looking at only 2 date cells, D5 and D6, then not sure if you need to use COUNTIF or COUNTIFS...

    You could put instead of the DATE() functions in the formulas, put the dates in 2 other cells and reference those in the formulas so that the DATE() function isn't needlessly getting recalculated everytime reducing the formula efficiency.
    Last edited by NBVC; 07-13-2011 at 09:10 AM.

  5. #5
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Date ranges withing date ranges

    Cool - Thanks for your help ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1