+ Reply to Thread
Results 1 to 16 of 16

Excel 2007 : Subtract date from a current date and show difference in months and days

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Subtract date from a current date and show difference in months and days

    Ok...to give scenario

    I need to subtract date of report from current date to work out how old the report is.

    So Column A is date of report and I need to have a number of months (report age) in column B

    I need to do this for multiple cells i.e. column A will have close to 200 dates

    In other words...when I enter the date of report in column A I would like to have the number in column B that shows how long since the report was generated





    So that's first part of the problem


    Also, is it possible then to, based on the value in Column B to have like Column C which will have another value that will be calculated based on age of report

    i.e. if report is more than 30 days old the value of 5 is automatically populated in column C

    something like

    if >1 then = 5
    if >2 then = 10
    if >3 then = 15

    1,2,3 referring to number of months and values 5,10, 15 referring to auto populated column C

    As in first case, I need solution for multiple entries

    Thanks all for your help in advance

  2. #2
    Forum Contributor
    Join Date
    07-24-2009
    Location
    Valrico, FL USA
    MS-Off Ver
    Excel 2016
    Posts
    358

    Re: Subtract date from a current date and show difference in months and days

    Ron,

    Assuming your dates start in A1, paste the first formula in cell B1 and the second formula in C1 then copy and paste the formulas down column B & C.
    There are probably better ways to do this.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    The first line '=IF(A1="","",(NOW()-A1)/30)' works okay but how do I get it to work for all Cells in A column ?

    Copying/pasting replicates the same calculation i.e. only taking into account A1 cell and current date

    It does not change to corresponding cell i.e. A2, A3, A4....

  4. #4
    Forum Contributor
    Join Date
    07-24-2009
    Location
    Valrico, FL USA
    MS-Off Ver
    Excel 2016
    Posts
    358

    Re: Subtract date from a current date and show difference in months and days

    Once the formulas are working in cells B1 and C1, select those 2 cells, copy then select all of the cells where you want the formulas, then paste.
    This should work.

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Subtract date from a current date and show difference in months and days

    I added the solution off ncmay in a workbook and added another solution.

    See the golden cells.

    With Vlookup in a table.

    Do you have questions, just ask.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    Thank you so much for that

    I now get calculations ok but in an odd format (see attachment)

    How do I get it to show in Months i.e.. 3.4,4.0, 5.5 etc
    Attached Images Attached Images

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Subtract date from a current date and show difference in months and days

    Change the format.

    Right mouse click => format => General

    Would that help?

  8. #8
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    Brilliant ! Thanks so much...

    I have a lot to learn, but I'm getting there

    Thanks so much

    I'll now keep going and post other problems if I hit the bump

  9. #9
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    13,764

    Re: Subtract date from a current date and show difference in months and days

    Glad I could help. Thanks for the reply.

    If the question is solved, will you mark your question as solved?

    If you got other questions, concerning Excel , just ask.

  10. #10
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Subtract date from a current date and show difference in months and days

    =DATEDIF(A1,TODAY(),"m") gives months =DATEDIF(A1,TODAY(),"md") gives remaining days so today 24/6/12 from 14/2/12 returns 4 and 9 respectively
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  11. #11
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    how do i assign the value to numbers in column B so it is automatically show in column E?

    so the values in column B are the result of calculation (current date - date of report = number in months)

    in other words....for example if number in column B is 5 the value in the column E should automatically populate as 10

    the score in E column will contribute towards total score in column S (not in the screenshot)

    i.e.

    <3 months = 0
    <6 months = 10
    <9 months = 15
    <12 months = 20
    <15 months = 25
    <18 months = 30
    <21 months = 35
    <24 months = 40
    <27 months = 45
    <30+ months = 50
    Last edited by ron burgundy; 06-25-2012 at 09:57 PM.

  12. #12
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    here is what i mean
    Attached Images Attached Images

  13. #13
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2013
    Posts
    4,335

    Re: Subtract date from a current date and show difference in months and days

    like this in Column E

    =LOOKUP(B1,{0,3,6,9,12,15,18,21,24,27},{0,10,15,20,25,30,35,40,45,"greater than/equal to 27??"})

    i put text to the last if the number in B is greater than/equal to 27 what value...change it then...
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  14. #14
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Subtract date from a current date and show difference in months and days

    =MIN(50,IF(CEILING(b1,3)/3=1,0,5*(CEILING(b1,3)/3)))

  15. #15
    Registered User
    Join Date
    06-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Subtract date from a current date and show difference in months and days

    Quote Originally Posted by martindwilson View Post
    =MIN(50,IF(CEILING(b1,3)/3=1,0,5*(CEILING(b1,3)/3)))
    This is just brilliant ! It works perfect ! I'm speechless !

    Now for god's sake can you explain how it works...

  16. #16
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Subtract date from a current date and show difference in months and days

    important change to formula scroll to end to see why

    CEILING(b1,3) rounds up a number to the nearest multiple of 3

    1rounds up to
    3
    2rounds up to 3
    3rounds up to 3
    4rounds up to 6
    5rounds up to 6
    6rounds up to 6
    7rounds up to 9
    divide the result by 3 5*CEILING(b1,3)/3
    then we get
    a series
    1
    1
    1
    2
    2
    2
    3
    3
    3
    you wanted a series 0,10,15,20...
    multiply by 5 CEILING(b1,3)/3
    5
    5
    5
    10
    10
    10
    15
    15
    15
    since we don't want the first 5 eliminate that with an if=5 then 0 statement
    IF(CEILING(b1,3)/3=1,0,5*(CEILING(b1,3)/3))
    so now

    1 goes to 0
    2 goes to0
    3 goes to0
    4 goes to 10
    5 goes to 10
    6 goes to 10
    7 goes to 15
    8 goes to 15
    9 goes to 15
    job done but at the other end of the scale

    26 goes to 45
    27 goes to 45
    28 goes to 50
    29 goes to 50
    30 goes to 50
    31 goes to 55
    so to limit the maximum to 50 you use MIN =MIN(a1,50) means it will always be 50 or less
    therefore =MIN(50,IF(CEILING(b1,3)/3=1,0,5*(CEILING(b1,3)/3)))
    having explained all that I see the borders of the formula are wrong you said
    <3 months = 0
    <6 months = 10
    <9 months = 15
    <12 months = 20
    <15 months = 25
    <18 months = 30
    <21 months = 35
    <24 months = 40
    <27 months = 45
    <30+ months = 50
    that formula gives

    <=3 months = 0
    <=6 months = 10
    <=9 months = 15
    <=12 months = 20
    <=15 months = 25
    <=18 months = 30
    <=21 months = 35
    <=24 months = 40
    <=27 months = 45
    <=30+ months = 50
    it needs adjusting with +1
    =IF(5*(CEILING(b1+1,3)/3)=5,0,5*(CEILING(b1+1,3)/3))
    well it was 4 am uk time
    Last edited by martindwilson; 06-26-2012 at 07:31 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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