+ Reply to Thread
Results 1 to 14 of 14

Subtract two date colums and count rows with specific values

  1. #1
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Subtract two date colums and count rows with specific values

    I am trying to find a formula which will and count and plot the number of people who registered within a particular time after account opening in column f. The formula is
    On a seperate sheet than the data.
    :
    Same day
    1-30 days
    31-60 days
    61 to 90 days
    >90 days
    Attached Images Attached Images
    Last edited by waylynjohnston1; 11-03-2016 at 06:04 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: Subtract two date colums and count rows with specific values

    Many members are unable to see images in the *.png format due to forum compatibility issues with some browsers.

    If you need to post an image post it in the *.jpg format.

    Even better than posting images... post a SMALL sample file. That way we can test solutions directly in the file with the relevant data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Subtract two date colums and count rows with specific values

    Thanks Tony,
    The data is below. I am trying to find the fomula for the Count Column.


    Name Open Date Register Date Registered Count
    Bob 1/20/2016 1/20/2016 Same Day 2
    Jan 1/1/2016 2/28/2016 1-30 Days 1
    Dave 2/10/2016 5/1/2016 31-60 Days 1
    Larry 1/31/2016 8/1/2016 61-90 Days 1
    Moe 4/1/2016 4/1/2016 >90 Days 1
    Curly 2/5/2016 2/7/2016

  4. #4
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Subtract two date colums and count rows with specific values

    Uploaded Jpg file.
    Attached Images Attached Images

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,847

    Re: Subtract two date colums and count rows with specific values

    As Tony said the best way to get help is by uploading a sample file such as the one attached.
    This solution adds two helper columns (D & E) which may be hidden for aesthetic purposes.
    The formula that populates the first helper column is: =DATEDIF(B2,C2,"d")
    The second helper column is populated with the lower boundary values of the succeeding 'Registered' label i.e. 1,31,61,and 91
    As an option you could use the bin numbers to populate the labels which would allow the changing of the labels by simply changing the values in that column.
    A formula to populate the labels could be: =E2&"-"&E3-1&" Days"
    The 'Count' column could then be populated with the formula: =COUNTIFS(D$2:D$7,">="&E1,D$2:D$7,"<"&E2)
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  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: Subtract two date colums and count rows with specific values

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    1
    Name
    Open Date
    Register Date
    -----
    From
    To
    Total
    2
    Bob
    1/20/2016
    1/20/2016
    0
    0
    2
    3
    Jan
    1/1/2016
    2/28/2016
    1
    30
    1
    4
    Dave
    2/10/2016
    5/1/2016
    31
    60
    1
    5
    Larry
    1/31/2016
    8/1/2016
    61
    90
    1
    6
    Moe
    4/1/2016
    4/1/2016
    91
    >91
    1
    7
    Curly
    2/5/2016
    2/7/2016


    This formula entered in G2 and copied down:

    =SUMPRODUCT(--(DATEDIF(B$2:B$7,C$2:C$7,"d")>=E2),--(DATEDIF(B$2:B$7,C$2:C$7,"d")<=F2))

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Subtract two date colums and count rows with specific values

    Simple ...

    =SUMPRODUCT(--(C$2:C$7-B$2:B$7>=E2),--(C$2:C$7-B$2:B$7<=F2))

  8. #8
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Subtract two date colums and count rows with specific values

    Thank you JeteMC, Tony Valko, and Phuocam. I used JeteMC solution. It worked but I'd like to approach the problem without helper columns as when I sort the raw data, the formulas become corrupted.

    I forgot to mention a very important detail. Some of the registration dates are prior to the open date. Therefore I am receiving a #NUM! Value in my results. I believe this is due to the negative value. Do you know a way to get around this issue of the #NUM! displaying?

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

    Re: Subtract two date colums and count rows with specific values

    Can you post a SMALL sample file and show us what result you expect?

    A SMALL file will have about 20 rows worth of data.

  10. #10
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Subtract two date colums and count rows with specific values

    While I can't post a file, in the example Tony posted on 11/3/16 at 7pm, if cell C6 is changed to 3/29/16, I would expect cell G2 to change to 1. With the current formula, if cell C6 is changed to 3/2/16, cell G2 changes to #NUM!.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,699

    Re: Subtract two date colums and count rows with specific values

    Try Phuocam's formula: gives result of 1 with changed date.

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

    Re: Subtract two date colums and count rows with specific values

    Quote Originally Posted by waylynjohnston1 View Post
    if cell C6 is changed to 3/29/16, I would expect cell G2 to change to 1. With the current formula, if cell C6 is changed to 3/2/16, cell G2 changes to #NUM!.
    If G2 should change to 1, shouldn't G3 change to 2?

    Try this...

    =SUMPRODUCT(--(ABS(C$2:C$7-B$2:B$7)>=E2),--(ABS(C$2:C$7-B$2:B$7)<=F2))

  13. #13
    Registered User
    Join Date
    11-16-2013
    Location
    san diego, CA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Subtract two date colums and count rows with specific values

    Tony Valko,
    That formula did the trick. Thank you Tony Valko, JohnTopley, Phuocam, and JeetMc for all the help in solving. Tony, I did want G2 to change to 1, and G3 to stay at 1, and the formula provided worked. This formula allows you to evaluate values contained in two columns of dates with multiple criteria using the sum product function. This is SOLVED. Thank you so much for your help!!!
    Waylyn

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

    Re: Subtract two date colums and count rows with specific values

    You're welcome. Thanks for the feedback!

+ 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] Count of specific values in a date range
    By bobbych in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-25-2015, 06:00 AM
  2. [SOLVED] Count duplicate values from multiple colums and rows
    By Perk1961 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-27-2015, 10:45 PM
  3. Count values in a row pertaining to a specific date range column
    By MattStolz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-23-2015, 03:21 PM
  4. Replies: 3
    Last Post: 09-23-2014, 02:48 PM
  5. [SOLVED] Count unique values on a specific date
    By Even in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-21-2014, 02:05 PM
  6. Count column w/blanks & values based on specific date
    By nickelcell1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-30-2009, 04:08 PM
  7. Count rows with specific date
    By lakegoddess in forum Excel General
    Replies: 3
    Last Post: 08-09-2005, 12:05 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