日期:2014-05-18  浏览次数:20808 次

求一条查询时间的SQL语句
求一条sql语句:现在数据库wfzj里边有一个表是 "案卷属性 ",在 "案卷属性 "表里有一列为 "建立时间 ", "建立时间 "里边的日期格式为 "2006-9-4   8:49:37 ",数据有1000多条,时间从05年-07年的数据都有,我现在想用sql语句,查询sql   server数据库的当前的年份对应查询出 "案卷属性 "表中 "建立时间 "列的相对数据该怎么查询?

------解决方案--------------------
select * from 案卷属性 where left(建立时间,4)=year(getdate())
------解决方案--------------------
select * from 案卷属性 where year(建立时间) = year(getdate())
------解决方案--------------------
select * from 案卷属性
where datepart(yy,建立时间)=datepart(yy,getdate())