+ Reply to Thread
Results 1 to 5 of 5

Date/Time Comparison

  1. #1
    Registered User
    Join Date
    03-22-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    17

    Date/Time Comparison

    I have a cell containing a Date and Time.

    1/16/2013 7:00am in A1 for example.

    I need a formula to check if this is 3:00am or not.

    I've tried all sorts of things and they don't seem to work.

    =IF(MOD(A1,1)-.125=0,"YES","NO") ??

  2. #2
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Date/Time Comparison

    Hi High_Road

    Try

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


    Merged Cells (They are the work of the devil!!!)

  3. #3
    Registered User
    Join Date
    03-22-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Date/Time Comparison

    So weird.

    So if I run =A1-INT(A1) on a Date/Time at 3:00am it returns .125 which is correct.
    But, as soon as I put it in the IF statement:
    =IF(A1-INT(A1)=(3/24),"YES","NO") it returns a NO??

  4. #4
    Registered User
    Join Date
    03-22-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Date/Time Comparison

    Ok...


    SO:

    =IF(AND(A1-INT(A1)>.124,A1-INT(A1)<.126),"YES",NO")

    This works, so A1-INT(A1) is >.124 and <.126 but not =.125?

    The dates and times stem from a TODAY() function. Does that maybe introduce some sort of discrepancy? I'll use the AND statement for now.

  5. #5
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Date/Time Comparison

    Hi

    That's right, If in A1:
    16/01/2013 03:00 = Yes
    16/01/2013 13:19 = No

+ 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