+ Reply to Thread
Results 1 to 22 of 22

convert Days into Month

  1. #1
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    convert Days into Month

    Hello excel experts...........


    I have a date (A1) 01-01-2010 (B1) 31-03-2010

    I put a formula for Years =DATEDIF(A1,B1,"Y")
    gives 0 Years

    I put a formula for Months =DATEDIF(A1,B1,"Ym")
    gives 02 Months

    I put a formula for Days =day(DATEDIF(A1,B1,"MD")+1)
    gives 31 Days

    but problem is it gives 31 days, but i want it shows 0days and Plus +1 in Month, should be 3
    The final result should be 0Years 03Months and 0Days
    how to calculate
    Attached Files Attached Files
    Last edited by AVG123; 01-02-2018 at 05:59 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    Try this:

    =DATEDIF(A1,B1+1,"Ym")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

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

    Re: convert Days into Month

    Give this try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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)

  4. #4
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: convert Days into Month

    Thanks for reply it is very simple.....what to do if
    DOB is (A2) 18-01-1965,
    DOA is (B2)15-04-1989
    DOR is (C2)14-11-2016
    The formula i have used DATEDIF(C2,D2,"y")&"Yr "&DATEDIF(C2,D2,"YM")&"Mn "&DAY(DATEDIF(C2,D2,"MD"))+1&"Dys" it gives result below
    27Yr 06Mn 31Dy

    but final result should be 27Yr 07Mn 0Dy
    how to solve this

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    This:

    =DATEDIF(C1,D1,"y")&"Yr "&DATEDIF(C1,D1+1,"YM")&"Mn "&DAY(DATEDIF(C1,D1+1,"MD"))+1&"Dys"

    The problem here is that your own calculations are incorrect, so however you try to 'solve' this, you are going to have 'errors' occurring at some point. You would be much better accepting that 01-01-2010 to 31-03-2010 is in fact 2 months and 31 days, NOT 3 months.
    Last edited by AliGW; 01-02-2018 at 05:35 AM.

  6. #6
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: convert Days into Month

    Thankyou but i want when it shows 31days, 31 days itself a month.........so increment of 1 in the Month and days should be 0 or blank

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    No, you are incorrect.

    01-01-2010 to 01-03-2010 is exactly 3 months. You have to see these not just as dates, but times, too.

    01-01-2010 00:00:00 to 31-10-2010 23.59.59 is one second less than three months.

  8. #8
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: convert Days into Month

    Thanks dear but what to do
    if
    DOB is (A2) 18-01-1965,
    DOA is (B2)15-04-1989
    DOR is (C2)14-11-2016
    The formula i have used DATEDIF(C2,D2,"y")&"Yr "&DATEDIF(C2,D2,"YM")&"Mn "&DAY(DATEDIF(C2,D2,"MD"))+1&"Dys" it gives result below
    27Yr 06Mn 31Dy

    but final result should be 27Yr 07Mn 0Dy
    how to solve this

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    No, it should not! Your calculations are incorrect, for the reasons I gave in my last post. To get the results you want, you need to change the second date in the formula.

    I have already shown you what to do to generate the incorrect outcome you want and I have also pointed out that this will cause issues for you at some point down the line (see post #5).
    Last edited by AliGW; 01-02-2018 at 05:49 AM.

  10. #10
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: convert Days into Month

    01-01-2010 00:00:00 to 31-10-2010 23.59.59 is one second less than three months. i think some mistake here.......


    01-01-2010 00:00:00 to 31-01-2010=1 month
    01-02-2010 00:00:00 to 28-02-2010=1 month
    01-03-2010 00:00:00 to 31-03-2010=1 month

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

    Re: convert Days into Month

    Upload some more example with expected result.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    Quote Originally Posted by gyan123 View Post
    01-01-2010 00:00:00 to 31-10-2010 23.59.59 is one second less than three months. i think some mistake here.......


    01-01-2010 00:00:00 to 31-01-2010=1 month
    01-02-2010 00:00:00 to 28-02-2010=1 month
    01-03-2010 00:00:00 to 31-03-2010=1 month
    No - you are absolutely incorrect. The latest time that the last day of the month can represent is a fraction of a second before midnight. Without any timestamp added, 31-03-2010 represents 31-03-2010 00:00:00, which is 23 hours and 59 minutes short of a full day.
    Last edited by AliGW; 01-02-2018 at 05:55 AM.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    Look at it this way: if you set up your bank account to make payments (let's say your gas bill) every 3 months, those payments will go out, for example, on 01-01-2018, 01-04-2018, 01-07-2018 and 01-10-2018.

  14. #14
    Forum Contributor
    Join Date
    02-17-2014
    Location
    INDIA
    MS-Off Ver
    Excel 2010
    Posts
    327

    Re: convert Days into Month

    I uploaded the softfile please see

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

    Re: convert Days into Month

    Try

    B11
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    2
    15.04.1989
    14.11.2016
    3
    4
    5
    6
    27
    7
    7
    8
    0
    9
    27Yr 7Mn 1Dys
    10
    27Yr 6Mn 31Dys
    11
    Final Answer should be 27Years 7Months and 0Days

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    No, you are incorrect (see post #13). To arrive at your desired result of exactly 27 years and 7 months, the end date must be set at 15/11/2016.

    Excel is not wrong - you need to accept the logic and work with it.

    EDIT: Shukla's formula will do what you want, but only because you want it that way, not because the answer is correct.
    Last edited by AliGW; 01-02-2018 at 06:05 AM.

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

    Re: convert Days into Month

    Ali actually he is correct i google it and the result is in the below snapshot
    Attached Images Attached Images

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    No, he is not correct - look at the tick box in your screenshot!!! What does it say? I have explained the logic in posts #7, #12 and #13.

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

    Re: convert Days into Month

    Yes your logic is absolutely correct but he wants to include last working day as well as.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    Yes, I know that HE wants to include that day, but he is saying that Excel is calculating it incorrectly, and Excel is NOT calculating it incorrectly. What he wants and what he is saying are two different things. I am trying to explain why Excel is calculating the date difference in the way it does. It can be overcome in several ways: I would have a hidden cell with the end date plus one day and use that in my DATEDIF calculation rather than trying to 'fudge' the formula to do something it's not designed to do.

    PS It's not really MY logic, it's EXCEL's logic, and it is mathematically correct.
    Last edited by AliGW; 01-02-2018 at 06:18 AM.

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: convert Days into Month

    @Gyan - do you understand what I have tried to explain to you? If you want help with my suggestion of a hidden cell, let me know.

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

    Re: convert Days into Month

    Quote Originally Posted by gyan123 View Post
    =DATEDIF(C2,D2,"y")&"Yr "&DATEDIF(C2,D2,"YM")&"Mn "&DAY(DATEDIF(C2,D2,"MD"))+1&"Dys"[/B]
    The DAY function here is unnecessary. If you want to count end date just add 1 to D2 in all 3 DATEDIF functions (as Ali suggests) but lose DAY function, e.g.

    =DATEDIF(C2,D2+1,"y")&"Yr "&DATEDIF(C2,D2+1,"YM")&"Mn "&DATEDIF(C2,D2+1,"MD")&"Dys"

    Quote Originally Posted by shukla.ankur281190 View Post
    =DATEDIF(A2,B2,"Y")&"Years "&IF(DAY(MEDIAN(EOMONTH(A2,0),EOMONTH(B2,0)))<=DAY(A2)+1+DAY(B2)+1,DATEDIF(A2,B2,"Ym")+1,DATEDIF(A2,B2,"Ym"))&"Months and "&IF(DAY(MEDIAN(EOMONTH(A2,0),EOMONTH(B2,0)))<=DAY(A2)+1+DAY(B2)+1,0,DAY(A2)+1+DAY(B2)+1)&"Days"
    Hello shukla,

    I see this working for the specific example but, in general, this formula isn't accurate. If A2 is 1-Jan-2018 and B2 is 1-Feb-2018 then your formula returns 0Years 1Months and 4Days!
    Audere est facere

+ 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. Convert days in month
    By AVG123 in forum Excel General
    Replies: 2
    Last Post: 08-28-2017, 10:22 AM
  2. [SOLVED] Calculation of days per month for dates beginning in one month and ending in another month
    By Fahrettin in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-07-2015, 04:52 PM
  3. [SOLVED] Determine work days in current month or next month based on day of the month
    By sbrnard in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-29-2014, 05:14 PM
  4. [SOLVED] Convert Month into days
    By Liana86 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-16-2014, 11:09 AM
  5. [SOLVED] Month convert into total days
    By michael_2013 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-23-2013, 07:43 AM
  6. convert month days and years into days
    By bokals in forum Excel General
    Replies: 6
    Last Post: 11-20-2011, 02:09 PM
  7. Convert Month in to days
    By Rahul Nagar in forum Excel General
    Replies: 4
    Last Post: 03-11-2010, 04:51 AM

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