+ Reply to Thread
Results 1 to 11 of 11

Split number of months from years

  1. #1
    Registered User
    Join Date
    07-04-2017
    Location
    Mumbai, India
    MS-Off Ver
    2010
    Posts
    5

    Split number of months from years

    Hi guys, I am new to the forum, and this is my first post.

    I get rent from my tenants, monthly. But, this does not happen regularly, ending up with arrears due to me.

    I have the current date in B1. [=today(0)

    When I receive a rent, I enter the date it in B2.

    I need to calculate the number of months rent is due by, say in B4.

    I can calculate this fairly easily in one of 2 ways:

    1) =DATEDIF(B2,B1,"m") or

    2) =(YEAR(B1)-YEAR(B2))*12+MONTH(B1)-MONTH(B2)

    This give me the total number of months in arrears.

    Now, I want to split up these months as arrears in preceding year (2016) and arrears this year (2017).

    For example, if the last rent received is for October 2016, I would like to get a result of 2 and 7, as of July 2017.

    To make matters slightly more complex, I often get rent in advance (wish that happened more often!). In this case, the DATEDIF formula goes for a toss, though the 2nd option works well. In this case, suppose I get paid upto, say, December 2017, I would like the results to be 0 and -5.

    Is there a way to achieve this?

    Many thanks and regards,

    Anand Dhuru

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Split number of months from years

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-04-2017
    Location
    Mumbai, India
    MS-Off Ver
    2010
    Posts
    5

    Re: Split number of months from years

    Thanks for the response.

    I am attaching the file as suggested.
    Attached Files Attached Files

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

    Re: Split number of months from years

    B11=datedif(max(edate(b2,0)+1,date(2016,1,1)),min(eomonth(b1,1),date(2017,1,1)),"m")
    b12=datedif(max(edate(b2,0)+1,date(2017,1,1)),min(eomonth(b1,1),date(2018,1,1)),"m")
    Samba

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

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Split number of months from years

    Another way. Try array entering this in B11.
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then this non array formula in B12.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You didn't ask but you could also array enter this in B5.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  6. #6
    Registered User
    Join Date
    07-04-2017
    Location
    Mumbai, India
    MS-Off Ver
    2010
    Posts
    5

    Re: Split number of months from years

    Siva, thanks, this works very well as long as the year in B2 is less than the current year in B1.

    But, if Year(B1) is equal to Year(B2), the formula

    =datedif(max(edate(b2,0)+1,date(2016,1,1)),min(eomonth(b1,1),date(2017,1,1)),"m" gives an error, and

    the next formula

    b12=datedif(max(edate(b2,0)+1,date(2017,1,1)),min(eomonth(b1,1),date(2018,1,1)),"m") shows 1 more than the actual value.

    Is there a way around this?

    Best Regards,

    Anand Dhuru

  7. #7
    Registered User
    Join Date
    07-04-2017
    Location
    Mumbai, India
    MS-Off Ver
    2010
    Posts
    5

    Re: Split number of months from years

    Dave, thanks for that pointer.

    I'm sure I'm being incredibly dense, but I somehow cannot get the Ctrl-Shift-Return to work; there seems to be no change to the active cell.

    What am I doing wrong?

    Best Regards,

    Anand Dhuru

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Split number of months from years

    You need to commit from edit mode. Either hit the F2 function key or mouse click in the formula bar. Holding down Ctrl + Shift hit Enter.

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

    Re: Split number of months from years

    See the attached file
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-04-2017
    Location
    Mumbai, India
    MS-Off Ver
    2010
    Posts
    5

    Re: Split number of months from years

    Siva, you are a life saver!

    Thanks, that works like a champ.

    Now, can I be a bit ambitious, and expect the last cell (2017) to show a negative number if I get paid in advance? Currently, it just shows a zero.

    For example, if I'm paid upto Dec 17, can that cell show -5?

    No matter if its too hassly, I can use your formula the way it is. But if it can be done, that would be perfection itself.

    Again, thanks, and regards.

    Anand Dhuru

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Split number of months from years

    RE: my formula above.

    In hind sight I should have extended the months argument of EDATE further ahead of any anticipated future date(s). My bad.

    Try array entering this in B1 and filling down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 07-22-2014, 02:15 AM
  2. Convert the number of weeks into years and months
    By Pickygame in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-16-2014, 12:19 PM
  3. Replies: 8
    Last Post: 02-20-2014, 05:46 PM
  4. [SOLVED] Split a figure by a given number of months in a finanacial years
    By SKirkaldy in forum Excel General
    Replies: 3
    Last Post: 09-11-2013, 01:03 AM
  5. [SOLVED] Age based on DOB; Accounts for leap years. Years old if >2, Months if <2 years old.
    By sharpmel in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-17-2013, 04:20 PM
  6. [SOLVED] Number of years/months/days between 2 dates
    By Deborah in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-07-2006, 06:30 AM
  7. [SOLVED] how do I convert a number to number of years, months and days
    By because in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-12-2005, 02:05 PM

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