clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1044276 fiddles created (9444 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 31/05/2019 00:00:00
 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 05/06/2019 00:00:00
 hidden batch(es)