MySQL Format Double Digit Month

November 3, 2017
DATE_FORMAT(created_date,‘%Y-%m’)

Use DATE_FORMAT function.

DATE_FORMAT(`created_date`,'%Y-%m')
# Output: 2017-01

The following produce single digit month.

DATE_FORMAT(`created_date`,'%Y-%c')
# Output: 2017-1

CONCAT(YEAR(`created_date`), '-', MONTH(`created_date`))
# Output: 2017-1
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.