clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601446 fiddles created (47989 in the last week).

--這是我初期設定 declare @basedate date = '2019/5/21'; declare @Setdate date = '2019/5/28'; declare @n int = 5; declare @addDay int = @n - (datediff(day,@basedate,@Setdate)) % ( @n ); --藉由日期間隔 - (輸入日期與基本日期天數差 Mod 日期間隔) 得出與下一個日期天數差 select @addDay diffDay,dateadd(day,@addDay,@Setdate) as CheckDay --輸入日期加上前面的天數差得到結果
diffDay CheckDay
3 2019-05-31
 hidden batch(es)


--這是我初期設定 declare @basedate date = '2019/5/21'; declare @Setdate date = '2019/5/31'; declare @n int = 5; declare @addDay int = @n - (datediff(day,@basedate,@Setdate)) % ( @n ); --藉由日期間隔 - (輸入日期與基本日期天數差 Mod 日期間隔) 得出與下一個日期天數差 select @addDay diffDay,dateadd(day,@addDay,@Setdate) as CheckDay --輸入日期加上前面的天數差得到結果
diffDay CheckDay
5 2019-06-05
 hidden batch(es)