+ Reply to Thread
Results 1 to 6 of 6

Compare dates

Hybrid View

  1. #1
    Registered User
    Join Date
    12-20-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    21

    Compare dates

    Hi All,

    Could you please help,,, I need a macro or a formula to check the deffirence between dates and give a reuslt in column c
    column A column B Today() Column C results
    11/09/2014 02/10/2014 < 1 month
    05/08/2014 02/10/2014 1 -3 month
    02/06/2014 02/10/2014 4-6 month
    30/03/2014 02/10/2014 7-12 month
    30/05/2013 02/10/2014 > 1 Year


    Thanx and Regards
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Compare dates

    Okay, your spreadsheet is a little wonky. It probably has something with you using =TODAY() in the B column, but since today (as I type this) is Oct 2, and your first row shows a start date of Aug 1, I'll assume that should be an output of 1-3 months, and not < 1 month.

    This equation works for the dates you provided in the text above:
    =CHOOSE(MATCH(DATEDIF(A2,B2,"m"),{0,1,3,6,12},1),"< 1 month","1-3 months","4-6 months","7-12 months",">1 year")

    Just drag it down the C column and you should be good. There is a caveat, in that the third example in your spreadsheet has Nov 2 in column A. DATEDIF expects the start date to be the first variable input, so if it is possible that column A date can occur after the column B date, you will need to check for it and adjust the formula above accordingly (using IF, MAX/MIN, IFERROR, or something along those lines).
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    12-20-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Compare dates

    Thanks Pauley..
    Iam getting error msg saying formula incomplete...
    Isit possible to ignore column B and add TODAY() to the formula..
    Isit possible to have the same in VBA MACRO.
    Thanx again for your help

  4. #4
    Registered User
    Join Date
    12-20-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Compare dates

    Hi Pauley,

    Sorry my mistake the formula Works fine.
    What should I add to the formula to add <1year if the diffrnc is greater than 1 year.
    Thanks again

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Compare dates

    Isit possible to ignore column B and add TODAY() to the formula..
    Yes, just replace B2 with TODAY()
    Isit possible to have the same in VBA MACRO
    Yes, but macros are always slower than a comparable formula solution
    What should I add to the formula to add <1year if the diffrnc is greater than 1 year
    I don't understand. I assume a typo. However, I recommend you use the Formulas->Evaluate Formula option in Excel to see how the formula works. I think once you see it in action, it is easy to understand and modify to your needs.

  6. #6
    Registered User
    Join Date
    12-20-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Compare dates

    Thanks Pauley
    You are a star.

+ 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] Best Way to Compare Dates
    By alcharbonneau in forum Excel General
    Replies: 3
    Last Post: 06-05-2012, 01:01 PM
  2. Compare two dates
    By MichaelM in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-24-2010, 01:26 PM
  3. How to compare dates
    By poojabans in forum Excel General
    Replies: 6
    Last Post: 05-18-2009, 12:05 PM
  4. Compare dates to ranges of dates
    By Santed593 in forum ExcelTip.com Feedback / Comments / Suggestions
    Replies: 1
    Last Post: 08-05-2005, 12:22 PM
  5. How can i compare dates?
    By aijihz in forum Excel General
    Replies: 4
    Last Post: 03-27-2005, 09:50 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