Page 1 of 1

SSRS_WEEK_CUR

Posted: Mon Feb 20, 2017 6:07 pm
by robinwilson16
Lists the current week number:

Code: Select all

CREATE FUNCTION [dbo].[SSRS_WEEK_CUR] (
	@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
	WHERE
		WN.StartDate <= GetDate()
		AND WN.EndDate >= GetDate()