Could anyone help me on how to convert a string such as 20050910 to a date format e.g 10/09/2005.
SELECT convert(datetime,'20050910') as myDateselect convert(varchar(20),convert(datetime,'20050910'),103) as myVarCharDate
Should do it.
Be very careful when and where you use dateconversions.
I sincerely hope that the poster wants to know this for the purpose of display only, and not for writing!
I, as a thinking (hopefully ) being cannot say if '10/09/2005' is 9th of October or 10th of September, so how can we expect that a computer would be able to? Be extremely careful not to use formats such as '10/09/2005' when you save dates to tables as datetimes. For that purpose you should use yyyymmdd format only.