Hi
I'm trying to Select Data from an Access DB.
I wrote this query to Select all Invoices that were Invoiced between two dates.
I get the following error
Syntax error (missing operator) in query expression 'Invoiced >=02/01/13 AND <= 05/01/13'

"SELECT * FROM invoiced_filter WHERE Invoiced > " & fromdte & " AND < " & todte

Thanks in Advence

Edited 3 Years Ago by VIPER5646

I don't have my dev machine so I can't test this but I believe the format for a date value is like

select * from tble where Invoiced > #01/05/2012#

so try

    "SELECT * FROM invoiced_filter " & _
    " WHERE Invoiced > #" & fromdte & "# AND < #" & todte & "#"
Comments
correct on date format

Thanks Reverend for your reply.
But the error still existes. Accept now the error is
"Syntax error (missing operator) in query expression 'Invoiced > #01/01/13# AND < # 05/01/13#'

        Dim datefrom, dateto As Date

        datefrom = Convert.ToDateTime(Trim(TextBox1.Text))
        dateto = Convert.ToDateTime(Trim(TextBox1.Text))

        Dim cmdload As New SqlCommand(("SELECT * FROM invoiced_filter WHERE invoiced BETWEEN '" & _
                                       datefrom.Date & "'  AND '" & _
                                       dateto.Date & "'"), con.con)

Jim has a minor error in his code:

 "SELECT * FROM invoiced_filter " & _
" WHERE (Invoiced > #" & fromdte & "# AND Invoiced < #" & todte & "#)"

Access also supports the Between statement but it requires the hash mark ("#") as Jim shown.

 "SELECT * FROM invoiced_filter " & _
" WHERE (Invoiced Between #" & fromdte & "# AND Invoiced < #" & todte & "#)"
Comments
That's why I like to test these things before posting ;-P

Thank You all for your replies
I guess all I was missing from my original QUERY was the table name Invoiced after the AND.
Here is the working QUERY

   SelectQueryString = "SELECT * FROM invoiced_filter & _ 
   WHERE (Invoiced >= #" & fromdte & "# AND Invoiced <= #" & todte & "#)"
This question has already been answered. Start a new discussion instead.