Get mySQL MONTH() to use leading zeros?

前端 未结 4 1171
夕颜
夕颜 2020-12-12 23:15

How do I specify to mySQL\'s MONTH() function to return \'08\' instead of 8 in this query?

I\'d like the sort to work datewise. Currently getting results for date l

4条回答
  •  孤街浪徒
    2020-12-13 00:06

    MONTH() returns an integer, so of course there's no leading zero. You will need to convert it to a string, left-pad the '0' and take the last 2 characters.

提交回复
热议问题