Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a simple way to check if dates are 1 year diffe
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01336573
Message ID:
01336577
Views:
9
This message has been marked as the solution to the initial question of the thread.
>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
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform