Results 1 to 5 of 5
  1. #1
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228

    simple "between dates" query

    hi all,

    i have a report that is based on a query with the following criteria:

    Between [forms]![frm_postetchreport]![txt_start] And [forms]![frm_postetchreport]![txt_end]

    if i choose the start and end date to be the same, my report comes up blank,
    if i choose the same start date and a later end date, then the data for the start day shows up.

    is my criteria wrong?



    thanks,
    j

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sometimes when the date has the time on it then this happens - the date becomes 01/01/2012 00:00:00. So your from date and to date will both be the same, i.e. zero seconds past midnight. Your search field will need to formatted to mm/dd/yyyy, maybe all the dates will.

  3. #3
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    sorry what do you mean by search field, the field in the query which contains this criteria?

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Yes, the date field you are wanting to match in between those dates.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, if the field includes a time component, it must handled:

    1. Include time in the criteria.
    Between [forms]![frm_postetchreport]![txt_start] & " 8:00:00 AM And " & [forms]![frm_postetchreport]![txt_end] & " 0:00:00 PM"
    or

    2. Format the field to drop the time part and filter only by the date. Just setting the format property in table is not enough (this doesn't change the underlying data). Use Format function to extract the date part and apply search criteria to this constructed field.
    CDate(Format(datefield, "mm/dd/yyyy")) Between [forms]![frm_postetchreport]![txt_start] And [forms]![frm_postetchreport]![txt_end]
    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.

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

Similar Threads

  1. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  2. Help with "simple" inventory system
    By waltb in forum Database Design
    Replies: 14
    Last Post: 07-06-2011, 01:45 AM
  3. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM
  4. Replies: 8
    Last Post: 02-24-2010, 01:49 PM
  5. a simple "display date " query
    By Ushera in forum Queries
    Replies: 2
    Last Post: 07-31-2009, 06:49 AM

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