WHERE (((tblNewCaseLog.CasePersonAddress) Like "*" & GetCriteria() & "*") AND ((DatePart("yyyy",
[DateLog])) Between DatePart("yyyy",Now())-1 And DatePart("yyyy",Now())))
ORDER BY tblNewCaseLog.DateLog DESC;
- 真的需要改进SQL 2008的旧Access语法以进行迁移。格拉西亚斯!
答案 0 :(得分:0)
WHERE tblNewCaseLog.CasePersonAddress Like '%' + @GetCriteria + '%'
AND
YEAR([DateLog]) Between YEAR(GETDATE())-1 And YEAR(GETDATE())
ORDER BY tblNewCaseLog.DateLog DESC;
更好的性能效率解决方案
WHERE tblNewCaseLog.CasePersonAddress Like '%' + @GetCriteria + '%'
AND
[DateLog] >= DATEADD(YEAR, DATEDIFF(YEAR,0,GETDATE()) -1, 0)
AND
[DateLog] <= DATEADD(YEAR, DATEDIFF(YEAR,0,GETDATE()) + 1, -1)
ORDER BY tblNewCaseLog.DateLog DESC;