I want to be able to convert the following string format to Datetime.
'21-04-2010 11:06'
I've looked here but there doesn't seem to be solution: http://msdn.microsoft.com/en-us/library/ms187928.aspx
convert(datetime, '21-04-2010 11:06', ??)
Has anyone else come across this problem? Or is it listed somewhere else?
Try this:
select convert(datetime, '21-04-2010 11:06', 105)
select convert(datetime, '21-04-2010 11:06', 105)
Here the ref http://www.w3schools.com/sql/func_convert.asp Basically is dd-mm-yyyy
format
You can use STR_TO_DATE date in MySQL to parse your String
If it is sql server, use 105...like this:
select convert(datetime, '21-04-2010 11:06', 105)
it will work (sql server docs says that it is for 21-04-2010 ...but it will get your 11:06, too)