Sie sind auf Seite 1von 1

GO

/****** Object: UserDefinedFunction [dbo].[GetDateBetweenDates] Script Date:


03-Nov-17 4:26:08 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE function [dbo].[GetDateBetweenDates] (@startDate datetime, @endDate
datetime)
returns nvarchar(4000)
as
begin
declare @csv nvarchar(4000) = ''
declare @maxDays int = DATEDIFF(DD, @startDate, @endDate)
declare @count int = 0
declare @date datetime
while(@count <= @maxDays )
begin

--if (DATENAME(dw, @date) = 'Saturday' OR DATENAME(dw, @date) = 'Sunday')


--BEGIN
-- set @count = @count + 1
-- CONTINUE
--END

set @date = DATEADD(d,@count, @startDate)


if (len(@csv) > 0) set @csv = @csv + ','
set @csv = @csv + DATENAME(day,@date)
-- + '-' + DATENAME(month,@date)

set @count = @count + 1

end
return @csv
end

Das könnte Ihnen auch gefallen