How to calculate datetime in hours? I have a date time field to input working hours and then I need calculate total work hours. I was try using Global math expression in views, but the results is 0, although I was try to change views formmater from date and time, ago and plain.

This is the condition, lets say the rule in office is:

Employee In 1: 08.00
Employee Out 1: 12.00
Employee In 2 : 13.00
Employee Out 2 : 17.00


It's mean that employees must have 8 hours a day.

The question is, how can I calculate that employee is late in 2 hours if the field value like this:

filed Employee In 1: 09.00 &lt;- late 
field Employee Out 1: 12.00 
field Employee In 2 : 13.00 
field Employee Out 2 : 16.00 &lt;- earlier out


Is there any module date related or some one chould assist me ho to solve my problem?
Have a look at the Computed Field module. Some details about it (from its project page):


  Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!


You may also want to look at its Community documentation, especially its child page about "Calculating a duration given a start and end time", here is a quote from it:


  ... create a new computed field to calculate the duration as a decimal number of hours (where 1.5 is 1 hour and 30 minutes).