Home > Software engineering >  Converting a wrong date into the correct format
Converting a wrong date into the correct format

Time:07-13

I have a wrong date in the database 2022-10-14 12:59:00 , I want to change it to 2022-14-10 12:59:00. Is there a direct convert function I could use, or do I have to split and put the date correctly. Just trying to get some ideas to do this the easy way. I tried the convert functions but I guess the original date as to be corrected first is it?

CodePudding user response:

You can use the CONVERT() function to go from a date type to a string with a particular "style". There are styles for different presentation formats to represent the different date presentation formats around the world.

To make this work, the data needs to be in a date type, not just a string. (or you can convert from a string type to a date type, then convert back to a string).

Date style descriptions

  • Related