Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Week Ending 21/01/2018
- Week Ending 28/01/2018
- Week Ending 04/02/2018
- Week Ending 11/02/2018
- Week Ending 18/02/2018
- Week Ending 25/02/2018
- Week Ending 04/03/2018
- Week Ending 22/01/2018
- Week Ending 29/01/2018
- Week Ending 05/02/2018
- Week Ending 12/02/2018
- Week Ending 19/02/2018
- Week Ending 26/02/2018
- Week Ending 05/03/2018
- SET @dteStartDate = CAST(@prmStartDate As smalldatetime)
- SET @dteEndDate = CAST(@prmEndDate As smalldatetime)
- DECLARE @MyTempTable TABLE (
- [tmpDate] [smalldatetime],
- [NumReferrals] [int] NULL
- )
- DECLARE @dteCurrent AS SMALLDATETIME
- DECLARE @NumReferrals AS INT
- SELECT @dteCurrent = dbo.fnGetEndOfWeek(@dteStartDate)
- WHILE @dteCurrent <= dbo.fnGetEndOfWeek(@dteEndDate)
- BEGIN
- --SELECT FROM DATA
- INSERT INTO @MyTempTable (tmpDate, NumReferrals) VALUES (@dteCurrent, @NumReferrals)
- SET @dteCurrent = DATEADD(Week, 1, @dteCurrent)
- END
- SELECT NumReferrals as Referrals,
- 'Week Ending ' + convert(nvarchar, tmpDate, 103) AS WeekEnding
- FROM @MyTempTable
- CREATE FUNCTION dbo.fnGetEndOfWeek
- (
- @prmInputDate smalldatetime
- )
- BEGIN
- Declare @AddNumOfDay INT
- -- If input date is not Sunday, move it foward to Sunday
- -- 1 Sunday
- -- 2 Monday
- -- ...
- -- 7 Saturday
- SELECT @AddNumOfDay = CASE (DATEPART(WEEKDAY, @prmInputDate))
- WHEN '2' THEN '6'
- WHEN '3' THEN '5'
- WHEN '4' THEN '4'
- WHEN '5' THEN '3'
- WHEN '6' THEN '2'
- WHEN '7' THEN '1'
- WHEN '1' THEN '0'
- END
- RETURN DATEADD(d,@AddNumOfDay,@prmInputDate)
- END
- Dim dtSeriesData As New Data.DataTable
- Using cmdGetSeries As SqlCommand = conLocal.CreateCommand()
- Using sqlSeries As SqlDataAdapter = New SqlDataAdapter()
- cmdGetSeries.CommandType = Data.CommandType.StoredProcedure
- cmdGetSeries.CommandText = sp
- For Each param As SqlParameter In sqlParams
- If Not param Is Nothing Then
- cmdGetSeries.Parameters.Add(param)
- End If
- Next
- Using dr As System.Data.Common.DbDataReader = cmdGetSeries.ExecuteReader()
- dtSeriesData.Load(dr) *
- End Using
- End Using
- cmdGetSeries.Parameters.Clear()
- End Using
- exec spGetGraphReferralsbyWeekAll @prmStartDate='18 Jan 2018',@prmEndDate='01 Mar 2018'
- Week Ending 21/01/2018
- Week Ending 28/01/2018
- Week Ending 04/02/2018
- Week Ending 11/02/2018
- Week Ending 18/02/2018
- Week Ending 25/02/2018
- Week Ending 04/03/2018
- Week Ending 22/01/2018
Add Comment
Please, Sign In to add comment