This topic is locked

Subtracting two fields and display on List and view page

6/4/2011 8:49:12 AM
PHPRunner General questions
I
itmanusa author

Hi,

I am hoping someone can help me with this. On my table, I have 2 time fields. On the Add page one in Time_In and the other is Time_Out. Both of these times will be in the same day. I have a 3rd field in the table called Total_Time (this is optional, I don't have to have this but would be good).
What I am wanting is when the user inputs time in and time out and saves that info, the list page to show the total time (Time_out-Time_In) next to that row. Optionally I would like to save this value in the Total_Time field of the table.
Any help would be greatly appreciated.
Thanks

J
John 6/4/2011



Hi,

I am hoping someone can help me with this. On my table, I have 2 time fields. On the Add page one in Time_In and the other is Time_Out. Both of these times will be in the same day. I have a 3rd field in the table called Total_Time (this is optional, I don't have to have this but would be good).
What I am wanting is when the user inputs time in and time out and saves that info, the list page to show the total time (Time_out-Time_In) next to that row. Optionally I would like to save this value in the Total_Time field of the table.
Any help would be greatly appreciated.
Thanks

J
John 6/4/2011

Add the line beginning with Time_To_Sec to your EDIT SQL page
Select

field1,

field2,

...

Time_To_Sec(TimeDiff(Time_Out, Time_In)) / 3600)) AS TotalTime

...

from ...
I wouldn't bother to save the total time value to the SQL table unless there is a compelling reason to do so.
John

I
itmanusa author 6/4/2011



Add the line beginning with Time_To_Sec to your EDIT SQL page
Select

field1,

field2,

...

Time_To_Sec(TimeDiff(Time_Out, Time_In)) / 3600)) AS TotalTime

...

from ...
I wouldn't bother to save the total time value to the SQL table unless there is a compelling reason to do so.
John


Hi John,

thanks for the reply. It worked perfect (I had to remove the 2 "))" after the 3600 for it to work). I am curious though, lets say if I did had to save the total for other uses (like get a grand-total for several days hours) how would I go about that.
once again thanks for your help.

Pinto