I am trying to pull records that are at least 7.5 years old but I can't get my stored procedure to work right. Can someone please help me? My stored procedure is as follows:
SELECT max(inout.inout_date) as 'lastdate', inout.account_number, loans.short_name from inout
INNER JOIN loans ON inout.account_number=loans.account_number
WHERE datediff(mm, 'lastdate',getdate()) >=111
GROUP BY inout.account_number, loans.short_name
The error message that I'm getting is:
Syntax error converting datetime from character string.
(inout.inout_date is a datetime field)