Search

The topic for datediff fails to mention that SET DATEFIRST does not apply by Erland Sommarskog

Active

1
0
Sign in
to vote
Type: Bug
ID: 775886
Opened: 1/5/2013 12:43:53 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
It is not unreasonable to expect that datediff(week, date1, date2) would respect the setting of SET DATEFIRST. However this is not the case, because that would make the function nondeterministic as discussed in the response to item
https://connect.microsoft.com/SQLServer/feedback/details/239958/datediff-function-and-the-first-day-of-the-week#details

There is no reason to change this, but since users may expect a different behaviour, there is all reason to explicitly point out in the topics for datediff() and SET DATEFIRST that the DATEFIRST setting is not applicable to datediff.
Details (expand)

Product Language

English

Version

SQL Server 2012 - Developer Edition

Category

Documentation

Operating System

Not Applicable

Operating System Language

Not Applicable

Steps to Reproduce

N/A

Actual Results

N/A

Expected Results

N/A

Platform

 

Virtualization

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/15/2013 at 12:09 PM
Thanks for the suggestion. Clarifying this behavior would indeed be useful.

Regards,
Gail Erickson
SQL Server Documentation Team
Sign in to post a workaround.