Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2008
    Posts
    19

    Question Unanswered: query from strat date to end date

    Hi

    I am using the following SELECT statment to disply the rows of data on a specific date:

    SELECT tblProject.MetDate, tblProject.Username
    FROM tblProject
    WHERE (((tblProject.MetDate) Like "22/08/2008"));

    What do i need to change so it will show the data from a strat date to an end date "WHERE (((tblProject.MetDate) >= "22/08/2008" and <= 27/08/2208));

    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    WHERE tblProject.MetDate >= #22/08/2008#
    and tblProject.MetDate <= #27/08/2008#
    Code:
    WHERE tblProject.MetDate BETWEEN #22/08/2008# AND #27/08/2008#
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I prefer between personally, it's easier to write
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    one thing to bear in mind is that Access/JET like many db storage mechanisms stores dates and times in the date datatype. generaly its not a problem, but you do need to be careful if your date valeu is actaully a date time value.

    ferinstance...
    if you have selever dates
    01 / Jan / 2008 @ 12:32
    31 / Jan / 2008
    31 / Jan / 2008 @ 01:22
    30 / Jan / 2008 @ 23:59

    if you specify between #01/01/2008# and #01/31/2008#, effectively that means between #01/01/2008 @ 00:00# and #01/31/2008 @ 00:00#

    you will not get the row containing "31 / Jan / 2008 @ 01:22", as its time component is after midnight on the 31/01/2008.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Aug 2008
    Posts
    19
    Thanks for the feedback, it is much appreciated.

    I have another question. Is it possible to add to the query so when it filters between the dates that I can exclude duplicate data from the “Username” field (if the username is listed twice or three times the query will only show the one instance of the username.)

    Thanks

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You could GROUP BY the username and use DFirst or something on the MetDate.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    new question.. new thread....
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Aug 2008
    Posts
    19
    I will open a new thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •