I am creating an MVC app where I need to send out an email to all those records whose value (DateUpdated) are not updated in the Customer table.
My Customer table looks like this:
ID (PK)
Name
Address
DateLastUpdated
Now I have this MySql query:
SELECT * FROM users WHERE DateLastUpdated >= NOW() - INTERVAL 6 MONTH
How I will write it in T-SQL and perform this task in MVC3? Please help!
Your query should be:
SELECT * FROM users WHERE DateLastUpdated >= DateAdd(month, -6, getdate())Additionally, you may want to strip out the time portion so you are left with just the date e.g.
2011-04-12 00:00:00.000you can use this: