+ Reply to Thread
Results 1 to 7 of 7

Issue with Date-Time comparisons

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    5

    Issue with Date-Time comparisons

    Hi

    I have a formula which compares two calculated dates and times located in two difference cells (the cells are formatted as Custom dd/mm/yyyy hh:mm:ss). In a few circumstances, even though the dates-times are the same, the formula says they are not. For example, even though 05/06/2013 00:29:48 is in each cell, the comparison says they do not match. When I change the format to the date-time serial number, one is 41430.0206944445 and one is 41430.0206944444 - probably why the formula says they are different.
    Does anyone know how I can get around this?
    Thanks for your help.

    M

  2. #2
    Registered User
    Join Date
    10-30-2012
    Location
    Modlin , Poland
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    42

    Re: Issue with Date-Time comparisons

    Are you sure that seconds are the same ?
    The problem can be like: 05/06/2013 00:29:47 and 05/06/2013 00:29:48

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Issue with Date-Time comparisons

    This problem is due to the way MS uses floating point arithmetic. This article describes the problem and possible workarounds

  4. #4
    Registered User
    Join Date
    08-10-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Issue with Date-Time comparisons

    Hi

    Thanks for the help folks. katiespirations - both time and dates are identical. arthurbr - do you know if you can apply rounding to the date-time serial number?

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

    Re: Issue with Date-Time comparisons

    You could try rounding to the nearest second.

    A2 = some date/time

    =ROUND(A2*86400,0)/86400
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    08-10-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Issue with Date-Time comparisons

    Thanks for your help everyone.

    M

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

    Re: Issue with Date-Time comparisons

    You're welcome!

+ 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