I am tryin to substract 10 hours from the difference between starttime and endtime in the same query
SELECT id,
user_id,
starttid,
sluttid,
dato,
TIMEDIFF(sluttid, starttid) as hourDiff,
SUBBTIME(hourDiff, '10:00:00:0000') as overTime
FROM hours
WHERE user_id = :id
ORDER BY dato
My problem is that hourDiff does not work, it seems that mysql sees it as a column in this query.. - how can i do, what i am trying?
I think you meant to use SUBTIME
not SUBBTIME
. Repeat the expression that generates hourDiff
in SUBTIME
. Try this:
SELECT id,
user_id,
starttid,
sluttid,
dato,
TIMEDIFF(sluttid, starttid) as hourDiff,
SUBTIME(TIMEDIFF(sluttid, starttid), '10:00:00:0000') as overTime
FROM hours
WHERE user_id = :id
ORDER BY dato