MySQL : Select on timestamp column, change seconds to 00 and round minutes down to nearest 10

StackOverflow https://stackoverflow.com/questions/17703647

문제

I have a table with a timestamp column as this:

2013-04-05 22:33:50

2013-04-05 22:42:03

2013-04-05 22:42:03

I want to make a SELECT on it and receive results with seconds 00 and minutes rounded down to nearest 10. As:

2013-04-05 22:30:00

2013-04-05 22:40:00

2013-04-05 22:40:00

How is this done? I cannot update or insert on the table, only select.

도움이 되었습니까?

해결책

Here you go:

SELECT DATE_SUB(DATE_SUB(ticktick, INTERVAL MOD(MINUTE(ticktick),10) MINUTE), INTERVAL SECOND(ticktick) SECOND) FROM `table`
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top