我有下面的代码,我希望总数是 12:37:47,但我得到的是 12 的整数。这些是结果:类别 1 - 06:02:06类别 2 - 06:35:41总计 - 12我怎样才能得到 12:37:47 的总结果?$sql = "SELECT hesk_categories.name, COALESCE(NULLIF(SEC_TO_TIME(SUM(TIME_TO_SEC(TimeSpent))),0),'00:00:00') AS TimeSpent from hesk_categories left Join hesk_tickets on hesk_categories.id = hesk_tickets.category left join TimeSpent on hesk_tickets.id = TimeSpent.ID and (DateCreated between DATE_FORMAT(NOW() ,'%Y-%m-01') AND NOW() ) where hesk_categories.name <> 'Feature Request' group by hesk_categories.name";$query = mysqli_query($con, $sql);while ($row = mysqli_fetch_array($query)){ $TimeSpent = $row['TimeSpent']; $TimeSpent = $TimeSpent + $TimeSpent; $message.="<tr>"; $message.="<td>" . $row['name'] . "</td>"; $message.="<td>" . $row['TimeSpent'] . "</td>"; $message.="<tr>";}$message.="<tr>";$message.="<td>Total</td>"; if ($TimeSpent >= '10:00:00') { $message.="<td><b><font color='red'>" . $TimeSpent . " (Support Hours have exceeded 10 hours for the month.)</font></b></td>"; } else { $message.="<td>" . $TimeSpent . "</td>"; }$message.="</tr>";$message.="</table><br>";
1 回答
慕仙森
TA贡献1827条经验 获得超7个赞
我将此添加到查询中:
SUM(TIME_TO_SEC(TimeSpent)) as TimeSpentSeconds
这对于 if 语句:
if ($TimeSpentSeconds >= 36000)
{
$TimeSpentSeconds = $TimeSpentSeconds / 3600;
$message.="<td><b><font color='red'>" . number_format((float)$TimeSpentSeconds, 2, '.', '') . " hrs (Support Hours have exceeded 10 hours for the month.)</font></b></td>";
}
else
{
$TimeSpentSeconds = $TimeSpentSeconds / 3600;
$message.="<td>" . $number_format((float)$TimeSpentSeconds, 2, '.', '') . " hrs</td>";
}
做这份工作。
- 1 回答
- 0 关注
- 121 浏览
添加回答
举报
0/150
提交
取消