sql server - SQL - select data that have dates greater than a month in a year -
i have table called quiz
, has 3 columns:
enteryear entermonth quizmark 2013 7 9.5 2013 8 8.5 2013 9 9.75 2013 10 10 2013 11 7.75 2013 12 8.5 2014 1 5 2014 2 8.75 2014 3 10
now, want select entries enter after sept. of 2013 (including sept). tried wrong:
select * quiz q q.year>=2013 , q.month>=9
this omitted entries in 2014 since months less 9, want them in result since after sept. of 2013.
so then, tried this
select * quiz q convert(date, cast(q.year varchar(4))+'/'+cast(q.month varchar(2))+'/01')>='2013/9/01'
which showed result half second , disappeared giving error message:
msg 241, level 16, state 1, line 1 conversion failed when converting date and/or time character string."
can correct code achieve result, appreciated!
select * quiz q q.year>2013 or(q.year=2013 , q.month>=9)
Comments
Post a Comment