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