一个时间条件查询语句问怎么写!!急
语句如是:
SELECT UNIT_ID,SUM(BOROUGH_ADVICEASSISNUM)ADVICEASSISNUM,count(EXTEND_ID)EXTEND_ID,SUM(BOROUGH_ADVICESUBSIDY)ADVICESUBSIDY
FROM T_BYW_JZFF
WHERE SALVATION_YEAR_MON=@SALVATION_YEARMON AND REVIEW_UNIT_ID= "1 "
GROUP BY REVIEW_UNIT_ID
SALVATION_YEAR_MON 是时间字段为字符型
怎么样取到时间为当前系统时间的年月并做为条件进行查询
运行语句列SALVATION_YEAR_MON=200709
------解决方案--------------------select convert(varchar(6),getdate(),112)
------解决方案--------------------存储过程中经常用到的本周,本月,本年函数
Dateadd(wk,datediff(wk,0,getdate()),-1)
Dateadd(wk,datediff(wk,0,getdate()),6)
Dateadd(mm,datediff(mm,0,getdate()),0)
Dateadd(ms,-3,dateadd(mm,datediff(m,0,getdate())+1,0))
Dateadd(yy,datediff(yy,0,getdate()),0)
Dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1, 0))