Skip to content

Commit

Permalink
Merge pull request #73 from Azure-Samples/sqlextension
Browse files Browse the repository at this point in the history
Bug fix for date_trunc(week, expression)
  • Loading branch information
Matt Usher authored Dec 16, 2020
2 parents 55b99a9 + 9bc0b2a commit 52d7e3b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion SQL/Extension/functions/microsoft.date_trunc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ BEGIN
WHEN @unit = 'NANOSECOND' THEN DATEADD(NANOSECOND, DATEDIFF(NANOSECOND, 0, @expression), 0)

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

-- Quarter
WHEN @unit = 'QUARTER' THEN microsoft.FirstDayOfQuarter(@expression)
Expand Down

0 comments on commit 52d7e3b

Please sign in to comment.