Results 1 to 4 of 4
  1. #1
    Edward_ is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    38

    Using a General Date in a query criteria. Access 2002

    First I must say, I'm trying to test this issue in a Query, but things will end up in an SQL string in my VB app.



    I have been using a concatenated date + time(like below) for a few weeks in a test application with no issues, when suddenly today the query pulls random Sept (2, 3, 4, 5, 6, 7, 8, 9) 2015 dates rather than between to explicit dates. (ie. 9/9/2015 7:00:00 AM and 9/10/2015 7:00:00 AM)

    So in my test query I have a Time_In field (with data like: 9/3/2015 11:32:33 PM) and I'm trying to find the syntax for the criteria. Something like Criteria: Between "9/9/2015 7:00:00 AM" And "9/10/2015 7:00:00 AM" is pulling random dates.

    Any advice appreciated.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Would have to see the SQL of the query, but are you delimiting the dates with the hash marks (#) in the query?

  3. #3
    Edward_ is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    38
    Thanks

    I just tested: Between "#9/9/2015 7:00:00 AM#" And "#9/10/2015 7:00:00 AM#" which gives no results (of 40-60 possible).

    Here is the SQL of the current test query:
    SELECT tblData.Room, tblData.Dr, tblData.Group, tblData.Label, tblData.Time_In, tblData.Time_Out, tblData.Elapsed
    FROM tblData
    WHERE (((tblData.Time_In) Between "#9/9/2015 7:00:00 AM#" And "#9/10/2015 7:00:00 AM#"));

    Access added the quotation marks.

  4. #4
    Edward_ is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    38
    The DB fields were Text rather than DateTime.
    Changing them to DateTime made everything work.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-13-2015, 04:29 PM
  2. Replies: 2
    Last Post: 04-02-2015, 12:45 PM
  3. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  4. Access 2002 crosstab query
    By knoty in forum Queries
    Replies: 15
    Last Post: 06-25-2012, 02:39 AM
  5. Replies: 1
    Last Post: 01-30-2010, 04:45 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