+ Reply to Thread
Results 1 to 10 of 10

Calculate number of days between 2 dates & then assign a number based on the answer

  1. #1
    Registered User
    Join Date
    08-26-2009
    Location
    Ohio
    MS-Off Ver
    2010, 2013
    Posts
    11

    Question Calculate number of days between 2 dates & then assign a number based on the answer

    Can someone please help me create a spreadsheet with what I think will be a very simple formula?

    If date in B2 - date in A2 is 1 or less days, put a 1 in cell C2.
    If date in B2 - date in A2 is 7 or less days but more than 1, put a 2 in cell C2.
    If date in B2 - date in A2 is 30 or less days but more than 7, put a 3 in cell C2.
    If date in B2 - date in A2 is 90 or less days but more than 30, put a 4 in cell C2.
    If date in B2 - date in A2 is 91 days or more, put a 5 in cell C2.

    OR

    Another, maybe simpler, way of saying it is:

    If date in B2 - date in A2 is 1 or less days, put a 1 in cell C2.
    If date in B2 - date in A2 is 2-7 days, put a 2 in cell C2.
    If date in B2 - date in A2 is 8-30 days, put a 3 in cell C2.
    If date in B2 - date in A2 is 31-90 days, put a 4 in cell C2.
    If date in B2 - date in A2 is 91 days or more, put a 5 in cell C2.

    Thank you!
    Attached Files Attached Files
    Last edited by MrHappyGoLucky12; 03-22-2014 at 09:00 PM.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Please help me create a spreadsheet with a very simple formula

    Maybe this...

    =IFERROR(MATCH(B2-A2,{0,2,8,31,91}),"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    08-26-2009
    Location
    Ohio
    MS-Off Ver
    2010, 2013
    Posts
    11

    Re: Please help me create a spreadsheet with a very simple formula

    Biff in Pittsburgh,

    Thanks for your quick response. How do I make the current date automatically populate in cell B2?

    John in Youngstown

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Please help me create a spreadsheet with a very simple formula

    Like this...

    =TODAY()


    We used to party in Youngstown back in the 80's!

  5. #5
    Registered User
    Join Date
    08-26-2009
    Location
    Ohio
    MS-Off Ver
    2010, 2013
    Posts
    11

    Question Re: Please help me create a spreadsheet with a very simple formula

    Hey, Tony--

    What am I doing wrong? I'm not getting a value of 1, 2, 3, 4, or 5 in C2. See attached.

    John

    Now everyone in Youngstown goes to Pittsburgh to party!
    Attached Files Attached Files

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Please help me create a spreadsheet with a very simple formula

    I downloaded the file and it shows the correct result of 3.

    B2-A2 = 21

    21 falls into category 3:

    If date in B2 - date in A2 is 1 or less days, put a 1 in cell C2.
    If date in B2 - date in A2 is 2-7 days, put a 2 in cell C2.
    If date in B2 - date in A2 is 8-30 days, put a 3 in cell C2.
    If date in B2 - date in A2 is 31-90 days, put a 4 in cell C2.
    If date in B2 - date in A2 is 91 days or more, put a 5 in cell C2

  7. #7
    Registered User
    Join Date
    08-26-2009
    Location
    Ohio
    MS-Off Ver
    2010, 2013
    Posts
    11

    Question Re: Calculate number of days between 2 dates & then assign a number based on the answer

    I can't get a number in C2. I attached a screenshot of what I see. Can you post a screenshot of what you see? I also attached a screenshot of what I see what I click the Insert Function (fx) button with C2 selected. Does that look right? Also attached the spreadsheet. Thanks again for helping me with this.
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate number of days between 2 dates & then assign a number based on the answer

    OK, I see the problem but, once again, when I open the file I get the correct result of 3.

    I wonder why I get the result but you don't?

    The date in B2 is a TEXT value. It may look like a date but it's actually just a TEXT string that looks like a date. You can tell this because Excel aligns text to the left and numbers (dates) to the right. Widen column B and you'll see it more clearly. Notice how A2 is aligned right while B2 is aligned left.

    The cell is formatted as Date but that really doesn't matter. Do this:

    Select cell B2
    Double click
    Hit Enter

    The formula should now return the correct result.

  9. #9
    Registered User
    Join Date
    08-26-2009
    Location
    Ohio
    MS-Off Ver
    2010, 2013
    Posts
    11

    Re: Calculate number of days between 2 dates & then assign a number based on the answer

    So strange! The date in cell B2 here is formatted as a date. I formatted both A2 and B2 as a date when I made the spreadsheet and C2 as General. No screenshots, but I'm sure you'll take my word for it. I selected B2, double-clicked, hit Enter, and still got nothing. How strange! Can you save the working spreadsheet and attach it to a reply? Thanks for your help.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate number of days between 2 dates & then assign a number based on the answer

    OK, here's the file with the formula returning the correct result.

    Priorities(1).xlsx

+ 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. How to create a simple formula for a data dump
    By blue_izce8 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-07-2013, 06:32 PM
  2. how to create simple formula
    By rlc131993 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-04-2012, 06:55 PM
  3. Trying to create a simple formula or VBA to buy or sell stock
    By MMcCawley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-28-2012, 11:47 PM
  4. How do you create simple add/subtract formula?
    By Suomalainen in forum Excel General
    Replies: 6
    Last Post: 07-01-2008, 03:18 AM
  5. [SOLVED] i want to create a simple yes/no spreadsheet with a dot represent.
    By alaskatpj in forum Excel General
    Replies: 6
    Last Post: 04-23-2005, 07:06 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