Crystal 11, MS SQL, ODBC, Stored Procedure
The user gets prompted to enter 2 dates for the report.
I would like to take those dates and somehow split it out into weeks to display as column headers in a crosstab like this:
Wk1 Wk2 Wk3 Wk4
10.00 5.00 11.00 8.00
Right now I'm only grouping by user name but I'd like the second group to be these weeks.
It could be split up Monday through Sunday.
I wonder if I'm doing the stored procedure part right. I declare them:
DECLARE @startDate DATETIME
DECLARE @endDate DATETIME
Then:
IF ISDATE(@startDateStr) = 1
SET @startDate = CONVERT(datetime, @startDateStr)
ELSE
SET @startDateStr = GETDATE()
IF ISNULL(@endDateStr, '') = '' SELECT @endDateStr = @startDateStr
IF ISDATE(@endDateStr) = 1
SET @endDate = CONVERT(datetime, @endDateStr)
ELSE
SET @endDateStr = GETDATE()
I thought I'd start by trying to use DateDiff("w", {?@StartDateStr}, {?@EndDateStr}) in a formula but Crystal highlighted the start date parameter and said it needed a date.
Any thoughts on what I did wrong - or maybe there is a better way ...
Thanks -
The user gets prompted to enter 2 dates for the report.
I would like to take those dates and somehow split it out into weeks to display as column headers in a crosstab like this:
Wk1 Wk2 Wk3 Wk4
10.00 5.00 11.00 8.00
Right now I'm only grouping by user name but I'd like the second group to be these weeks.
It could be split up Monday through Sunday.
I wonder if I'm doing the stored procedure part right. I declare them:
DECLARE @startDate DATETIME
DECLARE @endDate DATETIME
Then:
IF ISDATE(@startDateStr) = 1
SET @startDate = CONVERT(datetime, @startDateStr)
ELSE
SET @startDateStr = GETDATE()
IF ISNULL(@endDateStr, '') = '' SELECT @endDateStr = @startDateStr
IF ISDATE(@endDateStr) = 1
SET @endDate = CONVERT(datetime, @endDateStr)
ELSE
SET @endDateStr = GETDATE()
I thought I'd start by trying to use DateDiff("w", {?@StartDateStr}, {?@EndDateStr}) in a formula but Crystal highlighted the start date parameter and said it needed a date.
Any thoughts on what I did wrong - or maybe there is a better way ...
Thanks -