July 3, 2012 at 9:46 pm
Thanks for sharing. 🙂
July 3, 2012 at 10:09 pm
Sigh. Ticked all the 'new' data types except 'date' for some reason. Clearly having an off day.
July 3, 2012 at 11:35 pm
There is no error for datetime2. I think answer should be date.
July 4, 2012 at 1:47 am
anil_24apr (7/3/2012)
There is no error for datetime2. I think answer should be date.
Not sure what you are talking about. I took my code from above and changed DATE to DATETIME2 and it errors just the same way as DATE.
July 20, 2012 at 12:02 pm
Duncan Pryde (7/3/2012)
Good question. Is this related to the behaviour of datetimes versus datetime2s with the british language setting?
SET LANGUAGE BRITISH
GO
DECLARE @datevar datetime2 = '2008-12-13'; -- no error, ymd format
SELECT @datevar;
GO
DECLARE @datevar datetime = '2008-12-13'; -- error, ydm format
SELECT @datevar;
GO
I can't find a specific reference, but it looks as though SET LANGUAGE BRITISH implicitly sets the dateformat to ydm for datetimes and smalldatetimes and to ymd for dates and datetime2s.
I guess it must be. And British people (like me) have great difficulty understanding why on earth this should be - we always use ymd or dmy, unlike Americans who tend to use myd. When month names (as opposed to numbers) are used we use d mon y or mon d y about equally, but dateformat is about the numeric formats.
edit: And please, everyone, vote for the connect item that Thomas dug up.
Tom
August 8, 2012 at 12:07 pm
Nice question.
Viewing 6 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply