Skip to content

Commit 9bc0b2a

Browse files
author
Matt Usher
committed
Bug fix for date_trunc(week, expression) to move the timestamp to 00:00:00
1 parent 602ab33 commit 9bc0b2a

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)