European format time - Convert string to Datetime

2019-08-03 01:02发布

问题:

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?

回答1:

Try this:

select convert(datetime, '21-04-2010 11:06', 105) 


回答2:

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



回答3:

You can use STR_TO_DATE date in MySQL to parse your String



回答4:

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)