How to convert varchar to datetime?

Asked

Viewed 426 times

1

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

For example:

04-12-2016 for 2016-12-04 16:00:00

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

1 answer

2

Bar(/):

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

With the dash(-):

SELECT data(str_to_date('06/01/2017 18:26', '%c/%e/%Y %H:%i'), '%Y-%m-%d %H:%m:%s')
  • The update would look like this: update conta_payment set dt_payment = date(str_to_date(dt_payment, '%c/%e/%Y'), '%Y-%m-%d %H:%m:%s'); ?????

  • @Paulocosta, yes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.