Reputation: 437
CONVERT(VARCHAR(11),Enrollment.[Enroll End],106)
I thought the above was supposed to return a date like '12 Jan 2016', it is instead returning dates like '15 Oca 2016'. Does anyone know why this is happening? I originally thought maybe the language was set incorrectly but it was not.
https://msdn.microsoft.com/en-us/library/ms187928.aspx denotes 106 with this
1 These style values return nondeterministic results. Includes all (yy) (without century) styles and a subset of (yyyy) (with century) styles.
I'm not sure if the above has something to do with it - though I am not entirely sure what they mean by nondeterministic results
Thanks for the help!
Upvotes: 3
Views: 68
Reputation: 1322
I hope this helps..
if local setting are different. always use dateformat
set dateformat dmy
declare @date datetime = '12-01-2016'
select CONVERT(VARCHAR(11),@date,106)
Upvotes: 0
Reputation: 47444
The values returned are non-deterministic because they rely on the locale settings of the user connection. In other words, you can run the same exact code from two different computers and get different results - you can't determine the result based solely on the parameters.
Make sure that your client machine is set to an English locale.
Upvotes: 2