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)
In SQL Server, you can use the DATEADD() function to get last 3 months (or n months) records.
Your syntax appears to be wrong.
That should be
UPDATE[TCTdb].[dbo].[Stock]
SET[Warehouse] = 'old'
WHERE [ManufacturedDate] <= DATEADD(mm, -3, GETDATE())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With