我试图只比较月份和年份。所以我将它转换为varchar。这个对吗?
(case
when s."AccMonth" >= 1 and s."AccMonth" <= 12
then cast(rtrim(s.accmonth) + s.accyear AS varchar) end)
>=
cast(month(s.InitialChargeDate) as varchar) + cast(year(s.InitialChargeDate) as varchar)
accmonth
&accyear
是类型INT
InitialChargeDate
是类型DATE