Total time elapsed for each day CakePHP & MySQL
id track_id start stop created
4 7 2011-09-28 22:22:21 2011-09-28 22:22:30 2011-09-28 22:22:21
3 7 2011-09-28 22:22:07 2011-09-28 22:22:12 2011-09-28 22:22:07
Given the mysql structure and data above and the model name of Lapse. What sort of find/conditions would i use to get the output in array format:
2011-09-28 => 1 minute (or the total calculation of Stops - Starts)
So i can output a date and total elapsed time for that day?开发者_运维问答
Thanks
I'm not sure, but try something along this line: 'fields'=>array('SUM(UNIX_TIMESTAMP(Model.stop) - UNIX_TIMESTAMP(Model.start))')
and 'group'=>'DATE_FORMAT(Model.created,"%Y-%m-%d")'
精彩评论