Results 1 to 6 of 6

Thread: Problem in searching data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    174

    Problem in searching data

    Dear All,

    Hope all in good tune.

    I am facing a problem. I want to search the records between two dates. I am using the command as:

    SELECT *
    FROM mybilldet
    WHERE customer='(6) SINHA AUTO DISTUBUTOR' and billdate between (01/07/2006 and 31/07/2006)
    ORDER BY billdate;

    also I have used

    SELECT *
    FROM mybilldet
    WHERE customer='(6) SINHA AUTO DISTUBUTOR' and billdate >=#01/07/2006# and billdate<=#31/07/2006#
    ORDER BY billdate;

    The billdate field is a date type field. I am using an Access database.

    But the above two commands are not working. The records are there in the database from 18/07/2006. If I use

    SELECT *
    FROM mybilldet
    WHERE customer='(6) SINHA AUTO DISTUBUTOR' and billdate >=#18/07/2006# and billdate<=#31/07/2006#
    ORDER BY billdate;

    then it is working. Can anybody help me out.

    Thanks in advance

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Problem in searching data

    you must use US date format
    VB Code:
    1. WHERE customer='(6) SINHA AUTO DISTUBUTOR' and billdate >=# format(01/07/2006, "mm/dd/yyyy") # and billdate<=# format(31/07/2006, "mm/dd/yyyy") #

    access requires date in that order
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: Problem in searching data

    u can also try with this
    VB Code:
    1. SELECT *
    2. FROM mybilldet
    3. WHERE customer='(6) SINHA AUTO DISTUBUTOR'
    4. and billdate between '01/07/2006' and '31/07/2006'
    5. ORDER BY billdate;

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    174

    Re: Problem in searching data

    Thanks SHABA. It worked fine. Thank you very very much because I was fool in applying braces in between operator.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: Problem in searching data

    plz mark it as resolved if ur problem has been solved

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    174

    Re: Problem in searching data

    Thanks NOSHABA. It worked fine. Thank you very very much because I was fool in applying braces in between operator.

Posting Permissions

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



Click Here to Expand Forum to Full Width