sql DateAdd

Declare @Today datetime
Set @Today = GetDate()

Declare @Birthday datetime
Set @Birthday = '2009-03-20 00:00:00'

If @Birthday <= (Select DateAdd(d,14,@Today))
Begin
	Print 'Birthday is within 14 days'
End
Else
Begin
	Print 'Birthday is not within 14 days'
End
Example of DateAdd usage to find out if a birthday is coming up.

Updated: Saturday 9th October 2010, 14:58pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.