bien une option est simple:
select sum(unix_timestamp(stop) -
unix_timestamp(start))/60 from table
where date(created) = '28-01-2011';
mysql> select now(), date_add(now(), interval 10 minute);
+---------------------+-------------------------------------+
| now() | date_add(now(), interval 10 minute) |
+---------------------+-------------------------------------+
| 2011-10-04 13:29:56 | 2011-10-04 13:39:56 |
+---------------------+-------------------------------------+
1 row in set (0.01 sec)
mysql> select sum(unix_timestamp(now()) -
unix_timestamp(date_add(now(), interval 10 minute)));
+----------------------------------------------------------------------------------+
| sum(unix_timestamp(now()) - unix_timestamp(date_add(now(), interval 10 minute))) |
+----------------------------------------------------------------------------------+
| -600 |
+----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select sum(unix_timestamp(now()) -
unix_timestamp(date_add(now(), interval 10 minute)))/60 ;
+---------------------------------------------------------------------------------------+
| sum(unix_timestamp(now()) - unix_timestamp(date_add(now(), interval 10 minute)))/60 |
+---------------------------------------------------------------------------------------+
| -10.0000 |
+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
-ce que ces colonnes sont de type 'DateTime' ou sont-ils des chaînes dans ce format: 'dd-mm-aaaa hh: mm'? –
type de colonne: horodatage. @ Markarkers – benhowdle89