Results 1 to 3 of 3
  1. #1
    topcat39 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    2

    Comparison Inconsistency

    I am using datediff and the comparison operators to determine if the difference between two dates is greater than a baseline time frame. Some of the returned rows shows what I expect, but some do not.

    Query Fields involved:
    Min_FRI: (This is the baseline time frame) Long Integer from another query
    LastMetBurn: Nz([MaxofBurnDate],#1/1/1900#) (First date to compare, but some records have null date)
    YrsSinceLast: DateDiff("yyyy",[LastMetBurn],[DateCrit]) (DateCrit comes from a second query)

    (All of the above display what I expect)

    IsEA:
    IIf([LastMetBurn]<>#1/1/1900#,[yrssincelast]>=[Min_FRI],-1)
    Basically, if the last burn was too long ago, return true, if it's within the parameters, return false, if there was no last burn, return true


    Here are two of the returned rows with DateCrit - 7/1/2013:
    Min_FRI LastMetBurn YrsSinceLast IsEA
    Sample 1 4 1/1/1998 15 0
    Sample 2 2 3/27/2008 5 -1
    Sample 3 2 5/22/2011 2 -1
    Sample 4 4 4/2/2003 10 0


    I have checked that being a 2 always works and a 4 doesn't, but I can find examples both ways.

    I have also tried replacing the calculated fields in the IsEA field (LastMetBurn, yrssincelast) with the expanded source used to, but it still doesn't work.

    Anyone have any ideas?
    TIA



    Terri

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,618
    The issue is Min_FRI and YrsSinceLast both appear to be treated as text values. This means alpha sort applies. 10 and 15 sort before 4 and 2 so they are less than 4 and 2, not greater than.

    I don't know why they are treated as text but can assure treatment as integer with CInt() function.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    topcat39 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    2
    Thank you!!! This works. I've been hitting my head against a brick wall most of this morning!
    Last edited by topcat39; 06-22-2013 at 12:24 PM. Reason: trying to mark post as solved

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comparison Query
    By mkc80 in forum Queries
    Replies: 3
    Last Post: 08-15-2012, 01:48 PM
  2. Comparison
    By raytackettsells in forum Queries
    Replies: 2
    Last Post: 08-06-2012, 05:30 PM
  3. Values comparison
    By Rekha V in forum Access
    Replies: 10
    Last Post: 03-24-2012, 10:29 PM
  4. Comparison
    By VICTOR HUGO in forum Access
    Replies: 8
    Last Post: 02-10-2010, 04:32 PM
  5. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums