Jump to content

Problem in Time


newphpbees

Recommended Posts

Hi..

 

 

I got an issue in getting the total time.

 

I have this code to get the sum of total time:

 

$result = mysql_query("INSERT INTO payroll.casual_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM payroll.casual_att WHERE DATE_FORMAT(LOGOUT, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') GROUP BY EMP_NO") or die(mysql_error()); 

 

Rendered:

09:00:00

09:00:00

09:00:00

08:00:00

08:00:00

07:48:00

 

and the result of this is 50:48

 

but I need result is 50:80

 

the minutes is divided to 60

 

Is there any way to get the 50:80 result.

 

 

Thank you so much..

Link to comment
Share on other sites

In payroll minutes was divided into 60.

 

i tried this:

  $TotHours = substr($Hours, 0, 3);
  $Minutes = substr($Hours,4,2);
  $Minutes = substr($Hours,3,2);
  $Minutes_Convert = ($Minutes / 60); 
  $Minutes_Convert = number_format($Minutes_Convert, 2, '.', '');
  $Hours = $TotHours + $Minutes_Convert;

but i encountered problem when TotHours  = 100 the substr was not capable.

Link to comment
Share on other sites

If you're going for percentage of time, rather than actual minutes, you might need to convert your hours into minutes, then add those to the remainer minutes, then divide it all by 60.

 

i.e., 04h30m = 240 + 30 = 270 / 60 = 4.5

 

And it would be a "." not a ":" when you're displaying the hours.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.