Hello,
i'm trying to display a table in an asp page witch contains 5 columns, 2 of them calculate the workdays(only weekdays) between two dates and a 3de the difference in workdays from the provious columns. The 2 remaining colums are projetinformation.
I found out how to calculate the workdays in sql en this seems to be ok. Bu i can only use the print function in the query analyser. How do i get this 3 calculations + the 2 projectionfomation items in one query.
DECLARE @Lastdate smalldatetime, @StartDate smalldatetime, @EndDate smalldatetime, @Counter1 tinyint, @Counter2 tinyint, @difference int
SET @StartDate = (select createdate from projects Where Projects_ID=1)
SET @EndDate = (select Deadline from projects Where Projects_ID=1)
SET @Lastdate = (select Lastupdatestatus from projects Where Projects_ID=1)
SET @Counter1= 0
SET @Counter2= 0
WHILE @StartDate <= @EndDate
BEGIN
IF DATEPART(weekday,@StartDate) BETWEEN 2 AND 6
BEGIN
SET @Counter1 = @Counter1 + 1
END
SET @StartDate = DATEADD(day,1,@StartDate)
END
Print @Counter1
SET @StartDate = (select createdate from projects Where Projects_ID=1)
WHILE @StartDate <= @LastDate
BEGIN
IF DATEPART(weekday,@StartDate) BETWEEN 2 AND 6
BEGIN
SET @Counter2 = @Counter2 + 1
END
SET @StartDate = DATEADD(day,1,@StartDate)
END
PRINT @Counter2
Set @difference = @Counter1 - @Counter2
PRINT @difference
Thanks Annemie
i'm trying to display a table in an asp page witch contains 5 columns, 2 of them calculate the workdays(only weekdays) between two dates and a 3de the difference in workdays from the provious columns. The 2 remaining colums are projetinformation.
I found out how to calculate the workdays in sql en this seems to be ok. Bu i can only use the print function in the query analyser. How do i get this 3 calculations + the 2 projectionfomation items in one query.
DECLARE @Lastdate smalldatetime, @StartDate smalldatetime, @EndDate smalldatetime, @Counter1 tinyint, @Counter2 tinyint, @difference int
SET @StartDate = (select createdate from projects Where Projects_ID=1)
SET @EndDate = (select Deadline from projects Where Projects_ID=1)
SET @Lastdate = (select Lastupdatestatus from projects Where Projects_ID=1)
SET @Counter1= 0
SET @Counter2= 0
WHILE @StartDate <= @EndDate
BEGIN
IF DATEPART(weekday,@StartDate) BETWEEN 2 AND 6
BEGIN
SET @Counter1 = @Counter1 + 1
END
SET @StartDate = DATEADD(day,1,@StartDate)
END
Print @Counter1
SET @StartDate = (select createdate from projects Where Projects_ID=1)
WHILE @StartDate <= @LastDate
BEGIN
IF DATEPART(weekday,@StartDate) BETWEEN 2 AND 6
BEGIN
SET @Counter2 = @Counter2 + 1
END
SET @StartDate = DATEADD(day,1,@StartDate)
END
PRINT @Counter2
Set @difference = @Counter1 - @Counter2
PRINT @difference
Thanks Annemie