Skip to content

Commit 52d7e3b

Browse files
author
Matt Usher
authored
Merge pull request #73 from Azure-Samples/sqlextension
Bug fix for date_trunc(week, expression)
2 parents 55b99a9 + 9bc0b2a commit 52d7e3b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

SQL/Extension/functions/microsoft.date_trunc.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ BEGIN
5151
WHEN @unit = 'NANOSECOND' THEN DATEADD(NANOSECOND, DATEDIFF(NANOSECOND, 0, @expression), 0)
5252

5353
-- Week
54-
WHEN @unit = 'W' OR @unit = 'WEEK' THEN DATEADD(DAY, -(DATEPART(WEEKDAY, @expression) - 1), @expression)
54+
WHEN @unit = 'W' OR @unit = 'WEEK' THEN DATEADD(DAY, -(DATEPART(WEEKDAY, @expression) - 1), DATEADD(DAY, DATEDIFF(DAY, 0, @expression), 0) )
5555

5656
-- Quarter
5757
WHEN @unit = 'QUARTER' THEN microsoft.FirstDayOfQuarter(@expression)

0 commit comments

Comments
 (0)