Viewing 7 posts - 1 through 7 (of 7 total)
  • Excel Date Range Counting
  • egb81
    Free Member

    I need to count the number of instances in a date range that are >1yr, 2yr, 3yr etc. i.e. between today and 1yr ago, between 1yr and 2yr ago and so on. I’m pretty sure it’s a COUNTIFS or COUNTIF formula and using the TODAY() function but I can’t get mine to work properly. Any suggestions?

    whatyadoinsucka
    Free Member

    i’d use system date minus date to get days, then code it from there

    =today()-datecol = fieldX

    then you could do an if formulae ie =if(fieldX<365,”year1″,if(fieldX<730,”Year2″,”year3etc”))) … etc

    to group the records under each heading year1 , year2 etc

    Superficial
    Free Member

    Dates in col A
    Col B formula =TODAY()-A1
    Copy down

    Then =countif(B1:B99, “>365”)

    There should be a single-cell way of doing it like countif(A1:A99, “>TODAY()-365”) but that syntax doesn’t seem to work so I just do it the less elegant way with another column.

    Superficial
    Free Member

    Why do I waste time on these little puzzles? Anyway here you go:

    =COUNTIF(A1:A99, “>”&TODAY()-365)

    P.S. You may find that the above formula doesn’t copy into Excel properly because it changes the quotation marks. If that happens, type it out again directly into Excel.

    whatyadoinsucka
    Free Member

    damn excel and accountants, a Database with proper SQL is the way

    Rubber_Buccaneer
    Full Member

    Are you all handling leap years OK?

    How about this for a long winded answer where the dates are in column A

    Past year

    =COUNTIFS(A:A,”>”&DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())),A:A,”<=”&TODAY())

    One to two years ago

    =COUNTIFS(A:A,”>”&DATE(YEAR(TODAY())-2,MONTH(TODAY()),DAY(TODAY())),A:A,”<=”&DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())))

    egb81
    Free Member

    damn excel and accountants, a Database with proper SQL is the way

    Not far from the truth there. The figures should have been produced by head office but for some reason aren’t. This leaves muggins here faffing around with Excel formulas.

    Cheers all. I’ve managed to get a working formula, albeit one that ignores leap years but the data won’t need to be accurate to that detail so I’ll figure that out further down the line.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Excel Date Range Counting’ is closed to new replies.