你如何测试东西是否超过 3 个月?
我在选择表中日期为今天之前 3 个月的行时遇到了一些麻烦.我尝试在我的 where 子句中使用 DATE(NOW() - INTERVAL 3 MONTH)
,但没有运气.如果项目超过 3 个月,我如何在 SQL Server 中进行检查?
I have been having some trouble to select the rows of my table which has a date of 3 months prior of today. I tried using DATE(NOW() - INTERVAL 3 MONTH)
in my where clause, but no luck. How do I check in SQL Server if a item is older than 3 months?
UPDATE[TCTdb].[dbo].[Stock]
SET[Warehouse] = 'old'
WHERE [ManufacturedDate] <= DATE(NOW() - INTERVAL 3 MONTH)
推荐答案
您的语法似乎有误.
应该是
UPDATE[TCTdb].[dbo].[Stock]
SET[Warehouse] = 'old'
WHERE [ManufacturedDate] <= DATEADD(mm, -3, GETDATE())
相关文章