Using:
SELECT C.Account, (RTRIM(N.FIRST) + ' ' + RTRIM(LTRIM(N.MIDDLE)) + ' ' + RTRIM(LTRIM(N.LAST)) + ' ' + LTRIM(N.SUFFIX)) AS OwnerName, DateAdd(dd, -1, C.ExpirationDate) as RealExpirationDate, C.Description, C.Type FROM CARD as C INNER JOIN NAME as N ON C.Account = N.Account WHERE (DateAdd(dd, -1, C.ExpirationDate) BETWEEN @StartDate AND @EndDate) AND C.Type IN(10,15,17,25)
or
SELECT * from ( SELECT C.Account, (RTRIM(N.FIRST) + ' ' + RTRIM(LTRIM(N.MIDDLE)) + ' ' + RTRIM(LTRIM(N.LAST)) + ' ' + LTRIM(N.SUFFIX)) AS OwnerName, DateAdd(dd, -1, C.ExpirationDate) as RealExpirationDate, C.Description, C.Type FROM CARD as C INNER JOIN NAME as N ON C.Account = N.Account WHERE C.Type IN(10,15,17,25) ) t WHERE RealExpirationDate BETWEEN @StartDate AND @EndDate
source share