I am trying to convert a date from DDMMYY
format to datetime
in SQL Server.
I am using the convert
command as follows
select CAST('121031' AS datetime) as d -- For YYMMDD
select convert (datetime, Stuff(Stuff('311012',5,0,'.'),3,0,'.'), 4)
Try like this :-
declare @val1 varchar(30)
select @val1=SUBSTRING('311012',1 ,2)+'/'+SUBSTRING('311012',3 ,2)+'/'+'20'+SUBSTRING('311012',5 ,2)
SELECT CONVERT(datetime,@val1,103)