June 22, 2019 at 1:08 pm
Hello ,
Can you help me in this Error
use tempdb ;
declare @date datetime ='2019-01-31 00:00:00.007'
select @date
i have this error
thanks
June 22, 2019 at 4:32 pm
I have run your script and this is the result I got, so, not sure how you got that error.
2019-01-31 00:00:00.007
Cheers,
John Esraelo
June 24, 2019 at 1:35 pm
You're using the format yyyy-MM-dd
and the datetime
datatype. For datetime
that format is ambiguous and is interpreted differently depending on the langauge. The only formats, regardless of language and datatype, that are unambiguous is yyyy-MM-ddThh:mm:ss.sssssss
and yyyyMMdd
, any other format could be interpreted a different way.
For the value you have ('2019-01-31 00:00:00.007'
) it would be interpreted in the format yyyy-dd-MM
, meaning it'll be intrepreted as the 1st day, of the 31st month in 2019; which obviously doesn't exist.
Use a language unambiguous format:
USE tempdb;
DECLARE @date datetime ='2019-01-31T00:00:00.007'
SELECT @date;
You can see that this works here.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
June 24, 2019 at 1:46 pm
I have run your script and this is the result I got, so, not sure how you got that error. 2019-01-31 00:00:00.007
Try this:
set language french;
use tempdb;
declare @date datetime ='2019-01-31 00:00:00.007'
select @date
Use ISO 8601 format to fix:
set language french;
use tempdb;
declare @date datetime ='2019-01-31T00:00:00.007'
select @date
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply