Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mysql total elapsed times from two dates
- id created start stop
- 1 28-01-2011 23:00 28-01-2011 23:00 28-01-2011 23:01
- 2 28-01-2011 23:10 28-01-2011 23:10 28-01-2011 23:11
- 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)
Add Comment
Please, Sign In to add comment