Query to convert from datetime to date mysql

后端 未结 5 732
春和景丽
春和景丽 2020-12-29 18:00

I am trying to get the date portion of a datetime field. I know I can get it with date_format, but that returns a string or \"varchar\" field. How can I convert the result t

5条回答
  •  攒了一身酷
    2020-12-29 18:43

    syntax of date_format:

    SELECT date_format(date_born, '%m/%d/%Y' ) as my_date FROM date_tbl
    
        '%W %D %M %Y %T'    -> Wednesday 5th May 2004 23:56:25
        '%a %b %e %Y %H:%i' -> Wed May 5 2004 23:56
        '%m/%d/%Y %T'       -> 05/05/2004 23:56:25
        '%d/%m/%Y'          -> 05/05/2004
        '%m-%d-%y'          -> 04-08-13
    

提交回复
热议问题