This topic is locked
[SOLVED]

 Calculating time

12/16/2009 12:54:23 PM
PHPRunner General questions
S
swanside author

I have two fields in a report table, The information in the report table comes from a csv import file.

The two fields are start time and finish time. The start time has something like 09:00 and the finish time has 10:00
How can I calculate this to hours once the file has been imported?

Cheers

Paul

Sergey Kornilov admin 12/16/2009

You can calculate time difference in SQL query using TIMEDIFF function (MySQL):

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timediff

S
swanside author 12/17/2009



You can calculate time difference in SQL query using TIMEDIFF function (MySQL):

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_timediff



Thnkas, but It only puts the information into the report from an imported file, so, once the file is imported, what do I need to do to get it to put the actual difference in the time into another field automatically, so file gets imported and when you go back to list there will be three fields, Start Time = 09:00 End Time = 10:05 which come from the imported CSV file then Actual Time = 1:05 for 1 hour and 5 mins?

Thanks

Paul.

Sergey Kornilov admin 12/17/2009

Use calculated field in your SQL query that builds a report. In this calculated field use TIMEDIFF function to calculate the time difference.

S
swanside author 12/18/2009

Cheers

I did this
(SELECT TIMEDIFF(R085,R086)) AS Time
and it works a treat.

Thanks for the help

Paul