## Calculate time difference

Hi,

Please tell me how can i calculate time difference

Code:
`select status,timestamp from `tablename` where date(timestamp)=date(2008-04-04);`
The result what I get is
1 | 2008-04-04 17:30:01 |
| 1 | 2008-04-04 17:40:01 |
| 1 | 2008-04-04 17:50:01 |
| 1 | 2008-04-04 18:00:01 |
| 1 | 2008-04-04 18:10:01 |
| 1 | 2008-04-04 18:20:02 |
| 1 | 2008-04-04 18:30:02 |
| 1 | 2008-04-04 18:40:01 |
| 1 | 2008-04-04 18:50:01 |
| 1 | 2008-04-04 19:00:02 |
| 1 | 2008-04-04 19:10:01 |
| 1 | 2008-04-04 19:20:02 |
| 1 | 2008-04-04 19:30:01 |
| 1 | 2008-04-04 19:40:01 |
| 1 | 2008-04-04 19:50:01 |
| 1 | 2008-04-04 20:00:01 |
| 1 | 2008-04-04 20:10:01 |
| 0 | 2008-04-04 20:20:01 |
| 0| 2008-04-04 20:30:01 |
| 1 | 2008-04-04 20:40:02 |
| 1 | 2008-04-04 20:50:01 |
| 1 | 2008-04-04 21:00:01 |
| 1 | 2008-04-04 21:10:01 |
| 1 | 2008-04-04 21:20:01 |
| 1 | 2008-04-04 21:30:01 |
| 0 | 2008-04-04 21:40:01 |
| 1 | 2008-04-04 21:50:01 |
| 1 | 2008-04-04 22:00:02 |
| 1 | 2008-04-04 22:10:02 |

Now how to calculate the time difference between the two fields when status is 0.
For example When status becomes 1 at 2008-04-04 20:40:02 so how can i calculate the difference as 20 minutes the status was down and when status is 0 at 2008-04-04 21:40:01 in the another row I should calculate the timediffernce as 10 min.