July 14, 2014 at 11:41 am
I have a date held in a varchar field in a temporary sql table and I want to convert it into a sql date and it doesn't work. I can replicate this as below -
So I run
select
cast ('14/02/2014' as date)
and I get a conversion failed error. what am I doing wrong ?
July 14, 2014 at 11:45 am
you'll wnat to set your session variable for dateformat to handle this for you:
SET DATEFORMAT DMY
select
cast ('14/02/2014' as date)
Lowell
July 15, 2014 at 3:41 pm
or use convert() with style 103
select convert(date, '14/02/2014', 103)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply