Skip to content

Commit c1a4dcf

Browse files
authored
Update dbo.uf_DateCalc.UserDefinedFunction.sql
1 parent d3988b9 commit c1a4dcf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dbo.uf_DateCalc.UserDefinedFunction.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ BEGIN;
5151
) x(Code, [Period], BeginDate, EndDate)
5252
WHERE x.Code = @DateCode OR @DateCode IS NULL
5353
UNION
54+
-- Handling for P7D and L7D style date codes
55+
-- Supporting only days for now. Months requires a bit more work to calcualte the end of month value.
5456
SELECT Code = UPPER(@DateCode)
5557
, [Label] = CONCAT_WS(' ', CASE LEFT(@DateCode, 1) WHEN 'L' THEN 'Last' WHEN 'P' THEN 'Previous' ELSE NULL END, t.[Value], 'days')
5658
, BeginDate = CONVERT(datetime2, x.BeginDate)
@@ -72,3 +74,5 @@ BEGIN;
7274
RETURN;
7375
END;
7476
GO
77+
78+
-- SELECT * FROM dbo.uf_DateCalc(NULL, NULL)

0 commit comments

Comments
 (0)