I'm running a simple select statement against a SQL Server 2008 R2 database, as follows:
select * from RM20101 where RMDTYPAL = 7 and DATEPART(y, RM20101.DOCDATE) < '2011'
The RM20101 table is a list of accounts receivable (i.e. "sales") documents. The syntax " where RMDTYPAL = 7" means to only return a list of credit memos. Finally, the "DATEPART" syntax is to return credit memos only where the year portion of the document's date is older than the year 2011.
But, if you look at the image that I have embedded, this statement is returning documents dated with the year 2013.
What am I doing wrong?