ReportDate字段,数据格式是什么?
如果是标准的yyyy-MM-dd日期格式,参考MySQL数据库语法:
SELECT * FROM dbo.[DailyReport] where ApprovalLevel=2 and DATE_FORMAT(ReportDate,'%Y')=DATE_FORMAT(NOW(),'%Y')
其它数据库,适当修改函数即可...
SELECT * FROM dbo.[DailyReport] where ApprovalLevel=2 and format(ReportDate,'yyyy') = format(GETDATE(),'yyyy')
或 SELECT * FROM dbo.[DailyReport] where ApprovalLevel=2 and CONVERT(varchar(4), ReportDate, 23) = CONVERT(varchar(4), GETDATE(), 23) 方法很多,灵活运用