--创建表 create table WeekDays( id int primary key identity(1,1), WeekDay nvarchar(20), Status int --判断是否启用 )
----添加一年的工作日 DECLARE @num int DECLARE @count int set @num = 1 set @count = 1 WHILE @num <=365 --时间跨度有闰年的就是366天 begin INSERT into WeekDays VALUES ( convert(nvarchar(10),dateadd(dd,@num, ‘2017-07-05‘),23),1)-- 2017-07-05 星期三 if @count=2 begin set @num = @num+3 set @count = @count+3 end else begin set @num = @num+1 set @count = @count+1 end IF @count = 8 set @count = 1 end
时间: 2024-10-11 15:22:30