Results 1 to 6 of 6
  1. #1
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31

    Date/Time Search Midnight Issue

    hello, i am using the between statements to search between two date periods and then between specific times on those dates. if i search with the following criteria:

    Start Date = 11/07/2011, End Date = 12/07/2011
    Start Time = 11:55:00 PM, End Time = 12:05:00 AM

    it returns wrong results. i think this is due to going over midnight to the next day so it searches between times 12.05AM to 11:55PM on a single day instead of 11.55PM to 12.05AM. Does anyone know how to get it to search past midnight? SQL code used is below.

    Thanks

    Text36 = start date
    Text38 = finish date
    Text9 = start time


    Text11 = finish time

    Code:

    SELECT DISTINCT Historical_Data.MessageNo, Historical_Data.DateTime, Historical_Data.UserName, Historical_Data.FCS, Historical_Data.KKSCode, Historical_Data.Message

    FROM Historical_Data

    WHERE DateValue((Historical_Data.DateTime) BETWEEN Forms!Main_Form!Text36 AND Forms!Main_Form!Text38 AND TimeValue(Historical_Data.DateTime) BETWEEN Forms!Main_Form!Text9 AND Forms!Main_Form!Text11));

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    12:05 am would not be 12/07/2011, it is 12/08/2011.
    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
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    hey, Oh sorry i forgot to say my date format is DD/MM/YYYY, not MM/DD/YYYY. so im still having this issue :S any ideas?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    I did some testing with the MM/DD/YYYY structure and that works. Is your date data actually stored as DD/MM/YYYY or is this just a display formatting?
    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.

  5. #5
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    hi,

    the date format is actually imported and stored in the database as DD/MM/YYYY, so no its not a display format. however it is a date/time field so the complete layout of the field data is "DD/MM/YYYY HH:MM:SS AM/PM". do you think this could be the issue?

    thanks for your response

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    That can be a problem.

    Google: Access dd/mm/yyyy

    Here is one http://databases.aspfaq.com/general/...d-for-all.html
    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. Need help with date issue.
    By ITChevyUSSNY in forum Reports
    Replies: 13
    Last Post: 02-05-2013, 10:06 AM
  2. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  3. Replies: 6
    Last Post: 01-04-2011, 05:43 PM
  4. Replies: 8
    Last Post: 05-24-2010, 04:24 AM
  5. access time display issue at liknked table
    By newaccess in forum Access
    Replies: 0
    Last Post: 05-14-2010, 09:24 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