SQL Query - Change date format in query to DD/MM/YYYY

后端 未结 5 1053
悲哀的现实
悲哀的现实 2021-02-19 06:13

What I\'m trying to achieve is fairly straight forward, to get one date format to another;

From This: Jan 30 2013 12:00:00:000AM To This: DD/MM/YYYY

5条回答
  •  忘掉有多难
    2021-02-19 06:41

    If you have a Date (or Datetime) column, look at http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

     SELECT DATE_FORMAT(datecolumn,'%d/%m/%Y') FROM ...
    

    Should do the job for MySQL, for SqlServer I'm sure there is an analog function. If you have a VARCHAR column, you might have at first to convert it to a date, see STR_TO_DATE for MySQL.

提交回复
热议问题