You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
4.8 KiB
72 lines
4.8 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_generate_activity_test] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP PROCEDURE [dbo].[sp_generate_activity_test]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_generate_activity_test] Script Date: 02.12.2016 09:08:55 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[sp_generate_activity_test]
|
|
@startdatum datetime,
|
|
@enddatum datetime,
|
|
@steuerdatum datetime,
|
|
@vorlauf int,
|
|
@periode int,
|
|
@Set_Activity int=0 output
|
|
|
|
as
|
|
declare @workdate datetime
|
|
---------------------------------------------------------------------------------------------------------------------------
|
|
--Vorlaufzeit in Tagen vom Startdatum abziehen. Wenn dieses nach dem aktuellen Tagesdatum liegt, keine Aktivität generieren
|
|
---------------------------------------------------------------------------------------------------------------------------
|
|
set @startdatum=dateadd(dd,@vorlauf*-1,@startdatum)
|
|
if @startdatum > @steuerdatum begin
|
|
set @set_activity = 0
|
|
return
|
|
end
|
|
|
|
---------------------------------------------------------------------------------------------------------------------------
|
|
-- Berechnung
|
|
-- 1=einmalig,2=täglich,3=wöchentlich,4=monatlich,5=zwei-monatlich,6=vierteljährlich,7=halbjährlich,8=jählrich
|
|
---------------------------------------------------------------------------------------------------------------------------
|
|
set @workdate=@startdatum
|
|
while @workdate < @enddatum begin
|
|
print @workdate
|
|
if @workdate=@steuerdatum begin
|
|
set @Set_Activity=1
|
|
print 'to select'
|
|
return
|
|
end
|
|
if @workdate > @steuerdatum begin
|
|
set @Set_Activity=0
|
|
print 'no select'
|
|
return
|
|
end
|
|
|
|
if @periode = 2 set @workdate=dateadd(dd,1,@workdate)
|
|
if @periode = 3 set @workdate=dateadd(ww,1,@workdate)
|
|
if @periode = 4 set @workdate=dateadd(mm,1,@workdate)
|
|
if @periode = 5 set @workdate=dateadd(mm,2,@workdate)
|
|
if @periode = 6 set @workdate=dateadd(qq,1,@workdate)
|
|
if @periode = 7 set @workdate=dateadd(qq,2,@workdate)
|
|
if @periode = 8 set @workdate=dateadd(yy,1,@workdate)
|
|
end
|
|
|
|
set @Set_Activity=0
|
|
print 'no selection'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GO
|