# Perform time differennce calculation in mysql

**URL:** <https://forum.kirupa.com/t/perform-time-differennce-calculation-in-mysql/311598>\
**Category:** programming\
**Created:** [July 12, 2010, 12:56am UTC](https://forum.kirupa.com/t/perform-time-differennce-calculation-in-mysql/311598 "2010-07-12T00:56:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiota](https://avatars.discourse-cdn.com/v4/letter/t/76d3ee/32.png) [@Tiota](https://forum.kirupa.com/u/Tiota)\
**Post date:** [July 12, 2010, 12:56am UTC](https://forum.kirupa.com/t/perform-time-differennce-calculation-in-mysql/311598/1 "2010-07-12T00:56:48Z")

</div>

I have a database which stores timein and timeout of staff in some company, I try to calculate the number of hrs spend by each staff on a particular day by running this query.

Select emp\_num, ts\_timein , ts\_timeout, abs(ts\_timein-ts\_timeout) AS NumberOfHrs  
From timesheet Where ts\_date = “2010-07-01”;

Results:

±--------±----------±-----------±------------+  
| emp\_num | ts\_timein | ts\_timeout | NumberOfHrs |  
±--------±----------±-----------±------------+  
| 2010ab | 08:04:00 | 04:16:00 | 38800 |  
| 2002150 | 08:04:00 | 04:17:00 | 38700 |  
| 2009207 | 08:04:00 | 04:21:00 | 38300 |  
| 2002147 | 08:04:00 | 04:39:00 | 36500 |  
| 456116 | 08:05:00 | 04:20:00 | 38500 |  
| 2009205 | 08:05:00 | 16:20:00 | 81500 |  
| 2002149 | 08:05:00 | 00:00:00 | 80500 |  
| 456105 | 08:06:00 | 00:00:00 | 80600 |  
| 2009211 | 08:06:00 | 04:18:00 | 38800 |  
| 2010A | 08:06:00 | 00:00:00 | 80600 |  
| 91048 | 08:06:00 | 00:00:00 | 80600 |

The column NumberOfHrs contains strange values. How can I change them to number of hrs ?

Help is pretty appriated …
