select statment using and access 2000

Posted on 2005-04-08
Last Modified: 2009-12-16
i have a table in access 2000  (empno,ampname,hiredate) and i am using forms to build the application ,,, now i want to retrive all the employees who started thier work between 2 dates i tried many select staments like below but they are  not working

com.CommandText = "select * from emp where empdate >= '" & CDate(txtDate1.Text) & "' And empdate <= '" & CDate(txtDate2.Text) &"' ;"

please how can i solve it thanx
Question by:loay
    LVL 8

    Expert Comment


    com.CommandText = "select * from emp where empdate >= " & CDate(txtDate1.Text) & " And empdate <= " & CDate(txtDate2.Text) &""

    don't need a ; ever......

    u dont need the cdate either could be

    com.CommandText = "select * from emp where empdate "'" & txtDate1.Text & " And empdate <= " & txtDate2.Text  &""

    LVL 2

    Accepted Solution

    Hi loay,

    Try this, I think that you will find that it works

    com.CommandText = "select * from emp where empdate Between #" & txtDate1.Text  & "# AND #" & txtDate2.Text   & "#"

    The pound signs (#) denote a DATE comparison.

    Hope this help,


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now