php - SQL Server: Given a year find everything (inclusive) from the year previous and given year -


i'm not familiar sql server syntax, imagine go this:

$year = 2010;  $query = mssql_query("select * dbo.events                        date between $year , $year-1"); 

i'm not sure how format $year in case.

you're close. assuming date column datetime datatype:

select *     dbo.events     datepart(year, date) between $year-1 , $year 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -