+ Reply to Thread
Results 1 to 12 of 12

Compare Dates/Times on Two Separate Sheets

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Compare Dates/Times on Two Separate Sheets

    I am trying to compare dates and times on two separate sheets. On Sheet1 I have a list of dates and times as m/dd/yyyy hh:mm. On Sheet2 I have a list of dates and times as m/dd/yyyy hh:mm. I use this formula in Sheet1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    which returns FALSE even though it should return TRUE. If I then enter the contents of Sheet 2 into Sheet 1 and use the formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    it correctly returns TRUE.

    It's the exact same data! Why is this happening?

    Yes, I know I can just copy the Sheet2 data into Sheet1 to get it to work, but it's inelegant and it gives me extra columns to hide (this data should be hidden from the person receiving the output) instead of just hiding a sheet. It's driving me nuts!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Compare Dates/Times on Two Separate Sheets

    It sounds like some of your data may be text, and not values/dates (dates are just "special" numbers). Test this with =isnumber(cell_ref) a FALSE indicates text.

    If 1 is text and the other is not, you can convert 1 to the other fairly easily, upload a sample and I will walk you through it
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Compare Dates/Times on Two Separate Sheets

    Quote Originally Posted by FDibbins View Post
    It sounds like some of your data may be text, and not values/dates
    That's what I thought at first, but I checked it like three times and nope, that's not it.

  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: Compare Dates/Times on Two Separate Sheets

    Can you post a SMALL sample file that shows the results you're getting with that formula?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Compare Dates/Times on Two Separate Sheets

    Turnaround Time Sample Corrected2.xlsx

    Here you go. Same formula, same data, different results.
    Last edited by dkcel; 04-29-2013 at 01:15 PM. Reason: Uploaded file with wrong formula

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Compare Dates/Times on Two Separate Sheets

    In your sample data...
    sheet1 A2 = 4/19/13 1:58 PM
    sheet2 A2 = 4/19/2013 5:00:00 PM
    your formula is asking...
    =IF(A1>'Sheet2'!A1,TRUE,FALSE)...I dont see that specfic formula in your file, but if I adjust it to...
    =IF(A2>'Sheet2'!A2,TRUE,FALSE)
    then sheet1 A2 is NOT larger than sheet2 A2, so the answer should be FALSE, which it is?

    If you are refering to sheet1 I2, then maybe add some absoluting?
    =IF(AND(D2>Weekend!$B$2,D2<Weekend!$B$3),E2-Weekend!B$3,0)

  7. #7
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Compare Dates/Times on Two Separate Sheets

    I uploaded the wrong sample originally. The correct sample does have absolutes as in your example. It's this one:

    Turnaround Time Sample Corrected2.xlsx

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Compare Dates/Times on Two Separate Sheets

    in your formula...

    C2>Weekend!$B$2 this is FALSE 4/19/13 2:57 PM > 4/19/2013 5:00:00 PM = FALSE
    D2<Weekend!$B$3 this is TRUE

    BUT because you are using AND, they both have to be TRUE for the AND() to be true, else it returns FALSE
    Im not sure what you are testing for, but maybe try using OR instead of AND?

  9. #9
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Compare Dates/Times on Two Separate Sheets

    It has to be both. That's the point. If the entry date was after 5pm on Friday AND before 8am on Monday then it was entered on the weekend and the turnaround should be completion time minus 8am on Monday. So something entered on Saturday and completed Monday at 11am should show 3 hours (Monday 11am - Monday 8am).

    If you look at column H, it has the exact same formula but it returns the correct results.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Compare Dates/Times on Two Separate Sheets

    Sorry, the formula in H is not the same as in I

    H2 =IF(AND(C2>F2 ,C2<G2) ,D2-G2,0)
    I2 =IF(AND(C2>Weekend!$B$2,D2<Weekend!$B$3),D2-Weekend!$B$3,0)

  11. #11
    Registered User
    Join Date
    09-24-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Compare Dates/Times on Two Separate Sheets

    Well well well. I wonder how many times I was going to look at that before I saw it.

    Thanks.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Compare Dates/Times on Two Separate Sheets

    hats ok, I looked a few times too, before I noticed

+ 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