Skip to content

Commit 09282c9

Browse files
committed
fix failure on week extraction tests
1 parent 1768047 commit 09282c9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql_server/pyodbc/operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def date_extract_sql(self, lookup_type, field_name):
157157
the SQL that extracts a value from the given date field field_name.
158158
"""
159159
if lookup_type == 'week_day':
160-
return "DATEPART(dw, %s)" % field_name
160+
return "DATEPART(weekday, %s)" % field_name
161+
elif lookup_type == 'week' and self.connection.sql_server_version >= 2008:
162+
return "DATEPART(iso_week, %s)" % field_name
161163
else:
162164
return "DATEPART(%s, %s)" % (lookup_type, field_name)
163165

0 commit comments

Comments
 (0)