+ Reply to Thread
Results 1 to 13 of 13

Calculate number of months for a specific year between 2 cells with dates in them

  1. #1
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Calculate number of months for a specific year between 2 cells with dates in them

    Hello All,

    I have a spreadsheet for multiple prepaid paid services that i will need to expense over the begin/end date of the expense. I have a cell where it calculates the number of months the service will need to be expensed. What I am trying to do is create a formula to count the number of months for a specific year below that falls between the begin date(Cell) and end date (Cell)... I will then multiply the number times the actual monthly expense.

    I have been doing this manually and I know this may be more complex to have automated. Any assistance would be greatly appreciated!


    Original Amount 2015 2016 2017 Total Amt Begin Date End Date # of Months
    9,209.00 ??????? ?????? ?????? 9,209.00 1/2/2015 7/5/2017 31

  2. #2
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Calculate months between 2 dates:

    =DATEDIF(MIN(A1:B1),MAX(A1:B1),"m")&" months "

  3. #3
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    I appreciate your reply Azumi. I have that formula to calculate the number of months for the whole duration.

    My question is how do I count the number of months that are only for 2017 that falls in between two different cells that contains the date "1/2/2015" (cell F2) and "7/5/2017" (cell G2)

  4. #4
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Please see this and hope the best
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Thanks. How do I open the file. I am new here and it keeps telling me to register to open it even though I am already logged in

  6. #6
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Ok Im write here :

    =IF(OR(VALUE(F5)<YEAR(F2),VALUE(F5)>YEAR(G2)),"",INT(MOD((ABS(IF(DATE(F5,1,1)>F2,DATE(F5,1,1),F2)-IF(DATE(F5,12,31)<G2,DATE(F5,12,31),G2)))/365,25,1)*12)&" months")

    F2=Start Date
    G2=End Date

    and

    F5=Year Criteria

  7. #7
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    I have entered the formula you gave and received the too many arguments error and do not see anything that stick out to being misplaced. Below are the values that i have for my formula. I believe we are close and was wandering if i could get your help one more time.. The answer im looking for should be "8" months that this "service" would be expensed in 2015

    =IF(OR(VALUE(F2)<YEAR(N3),VALUE(F2)>YEAR(O3)),"",INT(MOD((ABS(IF(DATE(F2,1,1)>N3,DATE(F2,1,1),N3)-IF(DATE(F2,12,31)<O3,DATE(F2,12,31),O3)))/365,25,1)*12)&" months")


    F2=2015
    N3= 5/1/2015
    O3= 7/1/2017

  8. #8
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Can you download my file on post #4?

    or try this link:
    https://www.dropbox.com/s/nks4h9q6qn...nths.xlsx?dl=0

  9. #9
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Your the man... Works perfect. I just had to manually add "1" to include the starting month when the formula counts the number of months in between.

    Thank you.

  10. #10
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    thanks for the feedback

  11. #11
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    One last question and I believe we are 95% there... Is there a way to ignore the the "day" in the date... All I need is the number of months and dont want to account for what day it started..... having the specific day there is causing some calculations to be shorter/longer than they should.

    =IF(OR(VALUE(N$1)<YEAR($V5),VALUE(N$1)>YEAR($W5)),"0",INT(MOD((ABS(IF(DATE(N$1,1,1)>$V5,DATE(N$1,1,1),$V5)-IF(DATE(N$1,12,31)<$W5,DATE(N$1,12,31),$W5)))/365.25,1)*12))

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Assuming start date in A2, end date in B2 and years in C1 and across you can use this formula in C2 copied across and down as required

    =IFERROR(DATEDIF(MAX($A2-DAY($A2)+1,DATE(C$1,1,1)),MIN($B2,DATE(C$1+1,1,0)),"m")+1,0)

    That will count any part of a month as a whole month
    Audere est facere

  13. #13
    Registered User
    Join Date
    03-22-2015
    Location
    LAs Vegas, NV
    MS-Off Ver
    2010
    Posts
    13

    Re: Calculate number of months for a specific year between 2 cells with dates in them

    Thank you. You guys are awesome!

+ 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. Calculate number of months in a specific year between two dates.
    By chickynee in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-09-2019, 07:29 PM
  2. How to calculate number of months by date range for a specific year?
    By redstyles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-20-2015, 05:53 PM
  3. Replies: 2
    Last Post: 06-21-2012, 08:17 PM
  4. Replies: 3
    Last Post: 03-12-2009, 09:54 AM
  5. Replies: 5
    Last Post: 06-07-2008, 02:32 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