I have a string 010910 in ddMMyy format thatI have to cast this string a SQL Server datetime datatype, like 2010-09-01 00:00:00.000.
How can this be done?
I have a string 010910 in ddMMyy format thatI have to cast this string a SQL Server datetime datatype, like 2010-09-01 00:00:00.000.
How can this be done?
How about something like
DECLARE @String VARCHAR(6)
SELECT @String = '010910'
SELECT CONVERT(DATETIME,LEFT(@String,2) + '/' + SUBSTRING(@String, 3, 2) + '/' + RIGHT(@String,2),3)
Have a look at SQL Server Date Formats and CAST and CONVERT (Transact-SQL)