Page 1 of 1

SSRS_WEEK

Posted: Mon Feb 20, 2017 6:06 pm
by robinwilson16
Lists the week numbers and dates:

Code: Select all

CREATE FUNCTION [dbo].[SSRS_WEEK] (
	@Session VARCHAR(7)
)
RETURNS TABLE
AS
RETURN

--DECLARE @Session VARCHAR(7) = '2016-17'
	SELECT
		Code = WN.WeekNum,
		Description = FORMAT ( WN.WeekNum, '0#' ) + ' (' + FORMAT ( WN.StartDate, 'dd/MM/yyyy' ) + ' - ' + FORMAT ( WN.EndDate, 'dd/MM/yyyy' ) + ')'
	FROM GC.dbo.TVF_WeekNumbers ( @Session ) WN

	UNION ALL

	SELECT
		Code = NULL,
		Description = '-- All Weeks --'