+ Reply to Thread
Results 1 to 10 of 10

Compare date cell to two date columns

  1. #1
    Registered User
    Join Date
    07-03-2019
    Location
    Fort Worth, TX
    MS-Off Ver
    Office 365
    Posts
    4

    Compare date cell to two date columns

    Greetings!

    I don't know if this is possible, but what I am needing to do is compare a date/time cell to two date columns. For example, I have a column titled 'Date Created'. If this falls between any value in the 'Start Date' column and 'End Date' column, I want to use an IF statement to note that original row. The 'Start Date' and 'End Date' columns are on the same row, but I want the first date/time column to compare against all the rows.
    Last edited by bkpate; 07-03-2019 at 01:40 PM.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Compare date cell to two date columns

    What you are describing sounds doable but is it possible for you to mock up a sample workbook with enough representative examples AND expected results so people can give you the appropriate formula?
    use go advanced below this reply window then part way down click on manage attachments, then browse, upload, close and ok to upload a sample.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Compare date cell to two date columns

    Can you upload an example workbook? I'm unclear about what you expect. Do you want to return the two dates it's between in columns to the right or which row that combo is on? What if the Date/Time in E4 (for example) falls within multiple other lines (i.e E4 = 5/15/2019 and A1:B1 = 5/10/2019, 5/20/2019 and A17:B17 = 5/13/2019, 5/16/2019)?
    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    07-03-2019
    Location
    Fort Worth, TX
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Compare date cell to two date columns

    I've attached the file with a demo before and after...

    I tried this formula: =IF(AND(A5>=E:E,A5<=F:F),"On Task","Available"), but did not get the desired result.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Compare date cell to two date columns

    I assume that Row 7 is not on task because it appears before the two dates that would bracket it in row 8?

  6. #6
    Registered User
    Join Date
    07-03-2019
    Location
    Fort Worth, TX
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Compare date cell to two date columns

    Right. The logic is > than start date and < end date, not >= start date, <= end date.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Compare date cell to two date columns

    This formula in your sample data seems to work (In G2 copied down). If real data is more complex, give some examples.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Compare date cell to two date columns

    A7 is the same as A8 but A8 is on task

  9. #9
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Compare date cell to two date columns

    since I worked on it, I'm proposing mine too as an alternative. This appears to work though I think some of your examples are not coded correctly...
    =IF(SUM(COUNTIFS($E$2:$E$15,"<="&A5,$F$2:$F$15,">="&A5)),"On Task","Available")

    Deleted the ARRAY part, it works without making it an array.

    EDIT2: to get mine to work and return the same results as ChemistB's use this instead... =IF(SUM(COUNTIFS($E$2:$E2,"<="&A2,$F$2:$F2,">="&A2)),"On Task","Available") and drag down.
    Last edited by Sam Capricci; 07-03-2019 at 03:24 PM.

  10. #10
    Registered User
    Join Date
    07-03-2019
    Location
    Fort Worth, TX
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Compare date cell to two date columns

    Thanks so much! Worked like a charm!

+ 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] Formula to compare date (including month and year) from a listed date to today's date
    By mhewitson15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2014, 05:31 PM
  2. So simple, I can't believe I am posting it: compare date to date in a cell
    By GS7clw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2014, 12:54 PM
  3. [SOLVED] Convert a cell with a timestamp in it to just the date to compare to another date
    By Tanyab in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2013, 05:41 AM
  4. Compare current date to cell date
    By Alexm963 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2013, 06:49 PM
  5. How to compare system date with the date in cell of a ws?
    By techissue2008 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2009, 01:10 PM
  6. [SOLVED] Compare date in cell to date in Textbox
    By asmenut in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2006, 10:55 AM
  7. How to Get the sytem date and compare it with a date in an Excel cell
    By loulou in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-11-2005, 11:08 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