Results 1 to 2 of 2
  1. #1
    MichaelW is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    1

    Criteria or Filter Issue

    Hi,



    I am struggling a bit here so let me try and explain!

    I have two date columns in my table and query (Rec Date and Hasten Date).

    To begin, I had two simple expressions in my query:

    Days Early: [Rec Date]-[Hasten Date]

    Days Late: [Rec Date]-[Hasten Date]

    The query runs fine but obviously I have both sets of numbers (late and early) in my output. I tried adding criteria for "<=0" in Days Early and ">0" in Days Late but still have issues.

    So basically what I need is to display only numbers greater than "0" in my Days Late column and numbers less than or equal to "0" in my Days Early column.

    Am I going about this the right way or should I try something different?

    Thanks in advance!

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You will need to nest the date expressions within an IIF() function. I also recommend using the datediff() function rather than subtracting two date fields.

    Datediff("d", laterdate, soonerdate)

    For days early to be <=0, Hasten date must be greater than or equal to the rec date, if that is true return the number of days different:

    Days Early: IIF([Hasten Date]>=[Rec Date], datediff("d",[Hasten Date],[Rec Date]), NULL)

    Therefore days late would be as follows (just swap the true and false parts of the IIF())

    Days Early: IIF([Hasten Date]>=[Rec Date],NULL, datediff("d",[Hasten Date],[Rec Date]))

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

Similar Threads

  1. Filter By Form Report (combobox issue)
    By mike.burns7 in forum Reports
    Replies: 1
    Last Post: 06-10-2010, 07:42 PM
  2. Replies: 1
    Last Post: 02-03-2010, 08:17 AM
  3. Inch symbol in query filter criteria
    By sprovoyeur in forum Queries
    Replies: 3
    Last Post: 10-01-2009, 11:24 AM
  4. Criteria or Filter for Query
    By Ryan in forum Queries
    Replies: 1
    Last Post: 08-29-2009, 11:50 PM
  5. command button to filter a subform issue -
    By countdrako in forum Forms
    Replies: 1
    Last Post: 12-09-2005, 11:58 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