国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

sql:日期操作注意的,如果以字符串轉日期時的函數,因為數據量大,會出問題

2024-07-21 02:49:43
字體:
來源:轉載
供稿:網友
sql:日期操作注意的,如果以字符串轉日期時的函數,因為數據量大,會出問題
---1.以日期字符操作轉換日期 如果是Vip1生日不對,可以以上傳的數據日期為生日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(80),@total decimal,@vipno nvarchar(10),@now datetimedeclare @smonth varchar(2),@sday varchar(2)set @vipno='174030'set @now=getdate()select @birthday=birthday from vip1 where vipno=@vipno and birthday is not nullif isdate(@birthday)=0 or @birthday='1900-01-01'beginselect  @birthday=VipBirthdayDate from VipBirthdayAward where VipBirthdayNo=@vipnoendset @year=Year(@now)if month(@now)=1 and month(@birthday)=12begin   set @year=@year-1endif month(@now)=1 and month(@birthday)=11begin   set @year=@year-1endif month(@now)=2 and month(@birthday)=12 begin   set @year=@year-1endset @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'+@smonth  select @smonthendif len(@sday)<2begin  set @sday='0'+@sdayend set @str=cast(@year as varchar(4))+'/'+@smonth+'/'+@sday+' 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 時間加減操作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(80),@total decimal,@vipno nvarchar(10),@now datetime,@setyear datetimedeclare @smonth varchar(2),@sday varchar(2)set @vipno='174030'set @now=getdate()set @setyear=@nowselect @birthday=birthday from vip1 where vipno=@vipno and birthday is not nullif isdate(@birthday)=0 or @birthday='1900-01-01'beginselect  @birthday=VipBirthdayDate from VipBirthdayAward where VipBirthdayNo=@vipnoendset @year=Year(@now)if month(@now)=1 and month(@birthday)=12begin   set @year=@year-1   set @setyear=DATEDIFF(year,-1,@now)   select @setyearendif month(@now)=1 and month(@birthday)=11begin   set @year=@year-1   set @setyear=DATEDIFF(year,-1,@now)   select @setyearendif month(@now)=2 and month(@birthday)=12 begin   set @year=@year-1   set @setyear=DATEDIFF(year,-1,@now)   select @setyearendselect @birthday as 'birthday'set @month=month(@birthday)select @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 @NowBirthday=@setyearif isdate(@NowBirthday)=0begin   select @NowBirthday=DATEADD(yy, DATEDIFF(yy,0,getdate()), 0) endselect @NowBirthdayendGO

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 花莲市| 巴林左旗| 大同县| 太湖县| 白河县| 祁连县| 平湖市| 九寨沟县| 泉州市| 新晃| 唐海县| 杭州市| 会宁县| 本溪市| 鄄城县| 神农架林区| 普宁市| 密云县| 怀远县| 江安县| 萨嘎县| 特克斯县| 乳山市| 恩施市| 长葛市| 东乡县| 阳春市| 庐江县| 巢湖市| 三原县| 鹿邑县| 旬邑县| 屏南县| 二连浩特市| 任丘市| 北京市| 大庆市| 息烽县| 五家渠市| 临夏县| 涪陵区|