MYSQL Round the datetime to 15 minute

前端 未结 5 961
囚心锁ツ
囚心锁ツ 2021-01-17 12:58

I want to update the datetime round to 15 minutes in a MYSQL database table.

For Example:

If the dateTime is 2013-10-08 10:36:00, I want to conv

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 13:41

    You can modify answer you found (if you satisfied with it) just by concatenating date to the time:

    SELECT CONCAT(DATE(time_field), 
                  ' ',
                  SEC_TO_TIME((TIME_TO_SEC(time_field) DIV 900) * 900))
    FROM `your_table`  
    

提交回复
热议问题