benhowdle89
benhowdle89

Reputation: 37504

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

Upvotes: 0

Views: 239

Answers (1)

Anh Pham
Anh Pham

Reputation: 5481

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")'

Upvotes: 1

Related Questions