Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i`m using this queery


select * from RechargeReport where Date='convert(Varchar,Date,103) between '01/04/2013' and '24/04/2013''


and got a error

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '01'.


Thanks & regard
Hemant Mishra
Posted

SQL
select * 
from RechargeReport 
where Date between '2013/04/01' and '2013/04/24'

Happy Coding!
:)
 
Share this answer
 
Comments
h1emu:) 19-Apr-13 4:14am    
hi Aarti thanks
but I`m using datecasting
how i`m convert date into mm/dd/yyyy which come in dd/mm/yyyy
Aarti Meswania 19-Apr-13 4:16am    
what is datatype of "date" column?
varchar or datetime?
h1emu:) 19-Apr-13 4:18am    
Datetime
Aarti Meswania 19-Apr-13 4:23am    
then write query as I post in answer

it will give proper result

when compare date always pass dates in yyyy-MM-dd format
h1emu:) 19-Apr-13 4:41am    
Thanks
If [Date] field is a datetime type, you don't need to convert it as a string (varchar).
SQL
SELECT *
FROM RechargeReport
WHERE [Date] BETWEEN '01/04/2013' AND '24/04/2013'


If you want to convert [Date] string (varchar), you need to do that as follow:
SQL
SELECT *
FROM RechargeReport
WHERE CONVERT(VARCHAR(10),[Date],103) BETWEEN '01/04/2013' AND '24/04/2013'


In case of converting error, see this: SET DATEFORMAT[^]
 
Share this answer
 
Comments
h1emu:) 19-Apr-13 4:41am    
Thanks
Maciej Los 19-Apr-13 4:51am    
You're welcome, call again ;)
SQL
select *
from RechargeReport
where Date >= 2013/04/01 and Date39 <=2013/04/24
 
Share this answer
 

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