开发者

Total time elapsed for each day CakePHP & MySQL

开发者 https://www.devze.com 2023-04-10 07:29 出处:网络
idtrack_idstartstopcreated 472011-09-28 22:22:212011-09-28 22:22:302011-09-28 22:22:21 372011-09-28 22:22:072011-09-28 22:22:122011-09-28 22:22:07
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")'

0

精彩评论

暂无评论...
验证码 换一张
取 消