如何将vachar转换成int? [英] how to convert vachar to int ?
本文介绍了如何将vachar转换成int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是sql2008 r2的新手。我曾写过这样的查询
hi i am new to sql2008 r2 . Actuvally i wrote a query like this
select sum(Score) from student where id='1' and date>='01-june'+year(date)-1 and date<='30-july'+year(date)
喜欢这个错误即将来临
转换varchar值''01 -june-''转换为数据类型int
plz帮我
like this error is coming
convertion faild when converting the varchar value ''01-june-'' to datatype int
plz help me
推荐答案
试试这个
try this
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!
:)
这篇关于如何将vachar转换成int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文