>>Hi everybody,
>>
>>If there a way to check for two date variables to be exactly one year apart or not?
>>
>>Thanks in advance.
>
>DECLARE @Test1 datetime
>DECLARE @Test2 datetime
>
>SET @Test1 = '20080101'
>SET @Test2 = '20090101'
>
>SELECT CASE WHEN DATEADD(mm,12,@Test1) = @Test2
> THEN 'Hurray'
> ELSE ':-(((((' END AS TestMe
>
I solved it as
select case when ABS(datediff(dd,dateadd(yyyy,1,'08/19/2008'),'08/28/2009')) < 2 then 1 else 0 end as OneYearApart from People in the meantime. Let me test yours.
If it's not broken, fix it until it is.
My Blog