Update date to 1st day of the month in MySQL?
You can convert it to string to get the year and month and concatenate it with 01
.
UPDATE tableName
SET dateField = CONCAT(DATE_FORMAT(dateField, '%Y-%m-'), '01')
- SQLFiddle Demo
You can convert it to string to get the year and month and concatenate it with 01
.
UPDATE tableName
SET dateField = CONCAT(DATE_FORMAT(dateField, '%Y-%m-'), '01')