1
は、私が持っているものです。2桁の月変数と1桁の月変数をどのように比較できますか?ここ
select case when cast(datepart(mm, enrollments.enddate) as varchar)<cast(datepart(mm, getdate()) as varchar)
then 'Expired'
when cast(datepart(m, enrollments.enddate) as varchar)=cast(datepart(m, getdate()) as varchar)
then 'Renewal required by end of this month'
when cast(datepart(m, enrollments.enddate) as varchar)-1=cast(datepart(m, getdate()) as varchar)
then 'Renewal required by end of next month'
when cast(datepart(m, enrollments.enddate) as varchar)>cast(datepart(m, getdate()) as varchar)
then 'Current'
Else null
End) as [Certification Status]
すべての論理がenrollments.enddateの月の12 GETDATE月3を比較すると、結果は12 < 3その先導を示している最初のものを除いて働きます出力には、なぜあなたの代わりにn個の文字列として比較を行っているSQL Server 2008の
キャストをVARCHARとして停止し、代わりに数値を使用します。 –