zima10101
zima10101

Reputation: 307

Express timediff as tenth of an hour

Would like to add a record with the difference between two date/times expressed as tenths of an hour

e.g Start 2014-06-19 15:30:00 End 2014-06-19 18:00:00 Result 2.5

so far have

   SELECT 
   LEFT(
       (REPLACE(
           TIMEDIFF('2014-06-19 18:00:00','2014-06-19 15:30:00')
       ,':','.')
    ),5
    )/6

Which gives result 0.383 = not correct, any ideas welcome TQ

Upvotes: 1

Views: 57

Answers (1)

marekful
marekful

Reputation: 15351

You could calculate with seconds:

SELECT (UNIX_TIMESTAMP(date_a) -  UNIX_TIMESTAMP(date_b)) / 360

Upvotes: 2

Related Questions