Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am new to sql2008 r2 . Actuvally i wrote a query like this


SQL
select sum(Score) from student where id='1' and date>='01-june'+year(date)-1 and date<='30-july'+year(date)


like this error is coming
convertion faild when converting the varchar value '01-june-' to datatype int


plz help me
Posted
Updated 1-Apr-13 1:00am
v2

1 solution

try this
SQL
select sum(Score) from student where id='1' and date>= convert(datetime,convert(varchar(4),year(date)-1) + '-06-01') 
and
convert(datetime,convert(varchar(4),year(date)) + '-07-30') 

Happy Coding!
:)
 
Share this answer
 
Comments
Member 9846414 27-Apr-13 2:01am    
Thanku u very much i am happy .
Aarti Meswania 27-Apr-13 2:06am    
Most welcome!
Glad to help you! :)
please click on "Accept Solution" if it really helped you

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