+ Reply to Thread
Results 1 to 8 of 8

Count Certain months between two dates

  1. #1
    Registered User
    Join Date
    09-20-2015
    Location
    US
    MS-Off Ver
    O365
    Posts
    19

    Count Certain months between two dates

    Hey guys!

    I have found so much information on this site it's amazing! So first off thank you all!

    I have a new question that I can't seem to get an answer for. May be far fetched.

    I am trying to come up with a formula that will count CERTAIN months between two date ranges.

    Example:

    Cell A1 has 1/1/15
    Cell A2 has 1/1/16

    I need to count months June through November (6,7,8,9,10,11). The formula should return 6.


    I know how to count all months between, but I can't think of how to get those 6 months counted. Thank you all for your help in advance!
    Last edited by Goose0701; 09-25-2015 at 01:24 PM.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count Certain months between two dates

    Need more detailed information.

    Will the date range ever span many years like 1/1/2013 to 5/27/2020 and should each month of each year be counted?

    Should only full months that fall within the range get counted or should ANY month date that falls within the range get counted?

    How about posting SEVERAL examples and show us what each result should be.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    09-20-2015
    Location
    US
    MS-Off Ver
    O365
    Posts
    19
    Quote Originally Posted by Tony Valko View Post
    Need more detailed information.

    Will the date range ever span many years like 1/1/2013 to 5/27/2020 and should each month of each year be counted?

    Should only full months that fall within the range get counted or should ANY month date that falls within the range get counted?

    How about posting SEVERAL examples and show us what each result should be.
    Hi Tony.

    Thank you so much for your reply.

    Yes it will span more than one year and all occurrences of June through November should be counted.

    Also ANY month date that falls in the range should be counted. So even if it is one day in the month it should be counted.

    Examples:
    11/30/15 - 6/1/16 = 2
    1/1/13 - 7/12/17 = 26
    6/17/15 - 12/25/15 = 6
    11/15/15 - 11/1/16 = 7
    I hope this makes more sense now?

  4. #4
    Registered User
    Join Date
    09-10-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    61

    Re: Count Certain months between two dates

    Hi Goose,

    I have done up a working file for you to handle such situation. Please try it out and let me know if it works the way you want it.
    The workings should be able to cater for you if you need to calculated for other months as well.
    counting specified months between 2 dates.xlsx

    Enjoy and cheers.
    Ray

  5. #5
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Count Certain months between two dates

    May be =(YEAR(A3)-YEAR(A2))*SUM(1*ISTEXT(OFFSET($D$1,MATCH(A5,D2:D13,0),0,MATCH(B5,D2:D13,0)-MATCH(A5,D2:D13,0)+1,))) formula would work

    However please check the attached file. According your post #1
    Attached Files Attached Files
    Last edited by shukla.ankur281190; 09-25-2015 at 04:46 AM.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Count Certain months between two dates

    Hi All,

    I try using DATEDIF .

    In A1 start date, in B1 end date


    =DATEDIF(DATE(YEAR(A1),MONTH(A1),1),DATE(YEAR(A2),MONTH(A2),DAY(EOMONTH(A2,0))),"M")+1

    or more shortly:

    =DATEDIF(EOMONTH(A1,-1),EOMONTH(A2,0),"M")

    Hope that helps

    Edit: formula counts all month, not only june-november.
    Last edited by canapone; 09-25-2015 at 07:42 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count Certain months between two dates

    l16=SUMPRODUCT((MOD(MONTH(C16)+ROW(INDIRECT("1:"&DATEDIF(C16,EOMONTH(F16,1),"m")))-2,12)+1>5)*(MOD(MONTH(C16)+ROW(INDIRECT("1:"&DATEDIF(C16,EOMONTH(F16,1),"m")))-2,12)+1<12))
    Please Login or Register  to view this content.
    Try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  8. #8
    Registered User
    Join Date
    09-20-2015
    Location
    US
    MS-Off Ver
    O365
    Posts
    19

    Re: Count Certain months between two dates

    Thank you all so much! Ray, that was a good workup and it answered my question great, but it was a little more involved than I was thinking.

    Siva! You are my hero! That is exactly the formula I needed! Single cell, and tells me what I need. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Count Last Days of Months Between Two Dates
    By xybadog in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-13-2014, 10:10 AM
  2. [SOLVED] DATEIF: Count months between dates when...
    By Awdvgyjmko in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2014, 02:47 PM
  3. [SOLVED] Count number of months between two dates
    By nadeem.ansari1980 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-21-2014, 02:36 PM
  4. Count # of months between two dates and add rows
    By reltub in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-19-2012, 08:28 PM
  5. [SOLVED] Count days and months between two dates
    By nurer in forum Excel General
    Replies: 5
    Last Post: 05-23-2012, 10:53 AM
  6. Count Months Between Dates
    By jpgoeth in forum Excel General
    Replies: 3
    Last Post: 05-31-2007, 12:17 PM
  7. How to Count Months in a Column of Dates
    By Dexsquab in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-30-2006, 03:33 PM

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