---1. Convert date By date character if it is VIP1 birthday, you can upload the data date for birthdays Begindeclare @NowBirthday datetime, @birthday datetime, @stat datetime, @end datetime, @statbirthday datetime, @endbirthday datetime, @thirdbirthday datetime, @firthbirthday datetime, @year int,@ month int, @day int, @str varchar, @total decimal, @vipno nvarchar (ten), @now datetimedeclare @smonth varchar (2), @sday VA Rchar (2) Set @vipno = ' 174030 ' Set @now =getdate () Select @birthday =birthday from Vip1 where [email protected] and Birthday isn't Nullif isdate (@birthday) =0 or @birthday = ' 1900-01-01 ' beginselect @birthday =vipbirthdaydate from Vipbirthdayaward where [Email protected]endset @year =year (@now) if month (@now) =1 and Month (@birthday) =12begin set @[email protected]endif month (@now) =1 and Month (@birthday) =11begin set @[email protected]endif month (@now) =2 and Month (@birthday) =12 begin set @[email protected]endset @month =month (@birthday) Set @day =day (@birthday) SET @ Smonth=cast (@month as varchar (2)) Select @smonthset @sday =cast (@Day as varchar (2)) If Len (@smonth) <2begin Set @smonth = ' 0 ' [email protected] select @smonthendif len (@sday) < 2begin Set @sday = ' 0 ' [email protected]end set @str =cast (@year as varchar (4)) + '/' [email protected]+ '/' [email protected]+ ' 00:00:00 ' Set @NowBirthday =convert (datetime, @str)-----cast (@str as DateTime) if IsDate (@ Nowbirthday) =0begin Select @NowBirthday = ' 2014/01/01 00:00:00 ' endselect @NowBirthdayendGO---2 time plus minus operation Select DATEADD (yy , DATEDIFF (Yy,0,getdate ()), 0) begindeclare @NowBirthday datetime, @birthday datetime, @stat datetime, @end datetime,@ Statbirthday datetime, @endbirthday datetime, @thirdbirthday datetime, @firthbirthday datetime, @year int, @month int, @ Day int, @str varchar, @total decimal, @vipno nvarchar, @now datetime, @setyear datetimedeclare @smonth varchar (2), @sday varchar (2) Set @vipno = ' 174030 ' Set @now =getdate () set @[email protected]select @birthday =birthday from Vip1 where [email protected] and birthday are not nullif isdate (@birthday)=0 or @birthday = ' 1900-01-01 ' beginselect @birthday =vipbirthdaydate from Vipbirthdayaward where [email protected] Endset @year =year (@now) if month (@now) =1 and Month (@birthday) =12begin set @[email protected] set @setyear =datediff (Year,-1, @now) Select @setyearendif Month (@now) =1 and Month (@birthday) =11begin set @[email protected] set @sety Ear=datediff (year,-1, @now) Select @setyearendif Month (@now) =2 and Month (@birthday) =12 begin set @[email protected ] Set @setyear =datediff (year,-1, @now) Select @setyearendselect @birthday as ' birthday ' set @month =month (@birthday) Selec T @monthset @setyear =dateadd (year, DATEDIFF (year,0, @setyear), 0) set @setyear =dateadd (Month, @month-1, @setyear) Select @setyearset @day =day (@birthday) set @setyear =dateadd (Day, @day-1, @setyear) Select @[email protected]if IsDate (@ Nowbirthday) =0begin Select @NowBirthday =dateadd (yy, DATEDIFF (Yy,0,getdate ()), 0) Endselect @NowBirthdayendGO