How to convert varchar to datetime?

1

How to convert a date in varchar to datetime in the ?

For example:

04-12-2016 to 2016-12-04 16:00:00

04/12/2016 to 2016-12-04 16:00:00

    
asked by anonymous 06.01.2017 / 21:17

1 answer

2

With the bar ( / ):

SELECT str_to_date('06/01/2017 18:26','%m/%d/%Y %H:%i'); 

With dash ( - ):

SELECT data(str_to_date('06/01/2017 18:26', '%c/%e/%Y %H:%i'), '%Y-%m-%d %H:%m:%s')
    
06.01.2017 / 21:26