CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Calculate hours

Print topic Send  topic

Author Message
Backpuller
Posted: 11/18/2003, 2:05 PM

How to calculate hours

Using php+mysql

in the table i have a timeonline and timeoffline

i want to calculate the hours+minuts spent between

I'm using custom code BeforeShowRow

global $NewGrid1;
$TimeGrid->time_spent->SetValue(
($TimeGrid->offline_time->GetValue())
-
($TimeGrid->online_time->GetValue())
);

I must be doing something wrong, because i'm not getting any results
RonB
Posted: 11/24/2003, 9:24 AM

Use the functions in mysql to do this for you. The database is a lot faster at this stuf then php.
Assuming you enter the time in the hours:minutes format:

$TimeGrid->time_spent->SetValue(CCGetDBValue("SELECT sec_to_time( time_to_sec(" .$TimeGrid->offline_time->GetValue() .")- time_to_sec(" .$TimeGrid->online_time->GetValue() ."))",$DBConnection1);

Ron


Frans
Posted: 12/10/2003, 6:21 AM

I get a parse error with the code form Ron.

Did you solve it.

regards,
Frans
RonB
Posted: 12/12/2003, 1:38 AM

$TimeGrid->time_spent->SetValue(CCGetDBValue("SELECT sec_to_time( time_to_sec(" .$TimeGrid->offline_time->GetValue() .")- time_to_sec(" .$TimeGrid->online_time->GetValue() ."))",$DBConnection1));


I think it was missing an ) sorry :-)

Ron

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.