Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sSQL = "
SQL
SELECT * FROM tbl_Record WHERE [Date] between >=" & Format(fdate.Value, "MM/dd/yyyy") & " AND <=" & Format(tdate.Value, "MM/dd/yyyy") &
""


i always got error in this part...
Syntax error (missing operator) in query expression '[Date] between >=10/21/2014 AND <=11/03/2014'.

can someone help me... no indication of error...
thanks in advance...
Posted
Updated 3-Nov-14 4:13am
v2
Comments
Herman<T>.Instance 3-Nov-14 10:14am    
don't use < > and = in the Between function, so:
sSQL = string.Format("SELECT * FROM tbl_Record WHERE [Date] between {0} AND {1}", Format(fdate.Value, "MM/dd/yyyy"), Format(tdate.Value, "MM/dd/yyyy"));

The proper statement is:
SQL
SELECT *
FROM tbl_Record
WHERE [Date] BETWEEN '2014-09-03' AND '2014-11-03'


Symbols << and > are needed when you omit BETWEEN statement.
SQL
SELECT *
FROM tbl_Record
WHERE [Date] >= '2014-09-03' AND [Date] <= '2014-11-03'


Both queries are equal.

Note:
Do not use such of queries. Use stored procedured[^] instead.
 
Share this answer
 
v2
how to use between operator

http://www.w3schools.com/sql/sql_between.asp[^]
 
Share this answer
 
Comments
Maciej Los 3-Nov-14 10:36am    
+5
King Fisher 3-Nov-14 10:38am    
Thank you. Don't you Sleep?
Maciej Los 3-Nov-14 10:41am    
Sometimes... but short 4-5 hrs.
Now it's 4.40 PM in Poland

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900