Results 1 to 9 of 9
  1. #1
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34

    Search by Date only

    Hi All,

    I have a question below.

    I have a field in my table which is Date/time.
    It contain the date/time but when I search, i only want to search by the Date. It should not look at the time.
    I have a form created which the user will select the date and run the query.

    How can i do so?
    What is the SQL code to add in the query?

    The one i enter is



    WHERE((TBLCaseDetail.ReportedDateTime)=Format([Forms]![FormFindCase]![DateSelection],"dd/mm/yyyy"));

    Thanks in advance.

  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,770
    Try:

    WHERE Format([ReportedDateTime],"dd/mm/yyyy") =

    Review https://www.accessforums.net/access/...ate-46496.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.

  3. #3
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34
    Hi June7,

    Thanks for replying.
    I use the code below but is not working.

    Format([Forms]![FormFindCase]![ReportedDateTime],"dd/mm/yyyy") =[Forms]![FormFindCase]![DateSelection]

  4. #4
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34
    Hi June7,
    Sorry my code is below instead.

    Format(TBLCaseDetail.ReportedDateTime,"dd/mm/yyyy") =[Forms]![FormFindCase]![DateSelection]

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What does 'not working' mean - what happens?

    Did you review the referenced link discussing the issue of using non-U.S. date?
    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.

  6. #6
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34
    Hi June,

    What i mean is that i have a data which is for that date but when i run the query it does not pull out.

    I have read the link but dont really understand.

  7. #7
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34
    Hi All,

    Anyone can help please?

    I changed my data type for my date to Short Date and long date all does not help.
    I have a form which with a date selection with a button to run the query.

    My Query as below.

    SELECT TBLCaseDetail.CaseID, TBLCaseDetail.Status, TBLCaseDetail.ReportedDate, TBLCaseDetail.Type, TBLCaseDetail.Description
    FROM TBLCaseDetail
    WHERE (((TBLCaseDetail.Status)=[Forms]![FormFindCase]![StatusSelection]) AND #" & format([TBLCaseDetail.ReportedDate],"mm/dd/yyyy") & "# =[Forms]![FormFindCase]![DateSelection] AND ((TBLCaseDetail.Type)=[Forms]![FormFindCase]![CaseTypeSelection]));

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try not using the # characters. The Format function converts the date value to a string and the input in DateSelection is a string. This will compare string with string and hopefully the non-U.S. date structure will not be issue.
    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.

  9. #9
    mavisyew is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Aug 2014
    Posts
    34
    Hi June7,

    I got it.
    Thanks!

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

Similar Threads

  1. Search for date
    By azhar2006 in forum Forms
    Replies: 12
    Last Post: 07-10-2014, 10:02 AM
  2. Search By date (Today)
    By darwish in forum Programming
    Replies: 1
    Last Post: 03-07-2014, 03:46 AM
  3. Replies: 9
    Last Post: 11-25-2013, 04:33 PM
  4. Search date VBA but subform
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 10-15-2013, 10:39 PM
  5. Replies: 3
    Last Post: 09-11-2013, 09: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