以下是我在两个日期之间设置工作日的存储过程
Create procedure [dbo].[sp_workingdays](@startdate date,@enddate date,@createddatetime datetime,@adminid int)
as
declare @start date,@end date
declare @day varchar(50)
declare @timeid int
declare @daypare int
declare @workingdaytype varchar(20)
begin
set @start=@startdate
set @end=@enddate
while (@start<=@end)
begin
if @start not in (select Date from Generalholyday_details)
begin
select @day= DATENAME(dw,@start)
select @workingdaytype =case (DATEPART(DW,@start)+@@DATEFIRST)%7 when 1 then 'Leave Day' when 2 then 'Full Day' when 3 then 'Full Day' when 4 then 'Full Day'when 5 then 'Full Day' when 6 then 'Full Day' when 0 then 'Half Day' end
select @timeid=Time_id from Workingdaytimesetting_details where Workingday_type=@workingdaytype
insert into Workingday_details(Working_date,working_day,Time_id) values(@start,@day,@timeid)
update Workingday_details set createddatetime=@createddatetime where createddatetime is null
update Workingday_details set adminid=@adminid where adminid is null
end
set @start=DATEADD(day,1,@start)
end
end
GO
在 datepart 第 1 行是星期天。但实际上当我运行存储过程时,星期六我得到了 1。我如何为星期日设置 1。在我以前的系统中,我在相同的程序中为星期日设置了 1。