Sintaks Anda baik-baik saja, itu akan mengembalikan baris di mana LastAdDate
terletak dalam 6 bulan terakhir;
select cast('01-jan-1970' as datetime) as LastAdDate into #PubAdvTransData
union select GETDATE()
union select NULL
union select '01-feb-2010'
DECLARE @sp_Date DATETIME = DateAdd(m, -6, GETDATE())
SELECT * FROM #PubAdvTransData pat
WHERE (pat.LastAdDate > @sp_Date)
>2010-02-01 00:00:00.000
>2010-04-29 21:12:29.920
Apakah Anda yakin LastAdDate
bertipe DATETIME
?