Jump to content


Using SELECT SEC_TO_TIME on 2 fields

  • Please log in to reply
1 reply to this topic

#1 joesoaper

  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 21 April 2017 - 11:11 AM

Follow on posting to my previous post... had to take a totally new approach hence the new posting. As always any help or advice on how to find a solution is greatly appreciated.



I am trying to sum the total number of hours worked from 2 different fields - overtime_hours and overtime_hours1. I can get the code to run when only getting the information from one field, but am failing to get the same success when attempting to get it from 2 fields.


Here is the working code for one field.

$count_total_hours_worked = $pdo->query("SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `overtime_hours` ) ) )FROM dbase WHERE staff='Joe'  AND MONTH(CURDATE())=MONTH(serv_date) AND YEAR(serv_date) = YEAR(CURDATE()) ")->fetchColumn();     

#2 taquitosensei

  • Members
  • PipPipPip
  • Advanced Member
  • 622 posts

Posted 21 April 2017 - 12:42 PM


Edited by taquitosensei, 21 April 2017 - 12:44 PM.

"We don't necessarily discriminate. We simply exclude certain types of people."

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users