var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Converting text to date
I have a field that stores a date as text (121205). I need to convert this field to a date, but since it is text, I cannot figure out how to do it. Any ideas??? Thanks!
Amber Hardee, DBA
which database? informix? sybase? db2? access? firebird? oracle? mysql? sql server? postgresql?
Moving this thread to Microsoft SQL Server forum, but I'd use:
SELECT t, Convert(DATETIME, Stuff(Stuff(t, 5, 0, '/'), 3, 0, '/'))
FROM (SELECT '121205' AS t UNION SELECT '111105' UNION SELECT '101005') AS z
As you can tell, Pat likes to STUFF things....
So who's to say it's not 2012?
CREATE PROC mySproc99 @x text
SELECT CONVERT(datetime, CONVERT(varchar(25),@x))
EXEC mySproc99 '121205'
DROP PROC mySproc99
Brett is correct, you don't need the slashes in the US, and maybe not in the UK either... They assume a string of digits are MMDDYY. As far as I know, the slashes work in any locale.