date - Combine SUB_DATE AND TIMEDIFF to substract 1 hour in mysql -


i'm having problems timediff , date_sub. here mysql query:

select id, clock_user_id, clock_date,  (select clock_time aura_clock aura_clock.clock_type = 'start' ,    aura_clock.clock_date = t1.clock_date) start, (select clock_time   aura_clock aura_clock.clock_type = 'stop'   , aura_clock.clock_date =     t1.clock_date) stop, 

the problem start here

timediff((select clock_time aura_clock t  t.clock_date = t1.clock_date , t.clock_time > t1.clock_time  order t.clock_time limit 1), min(clock_time)) spent  aura_clock t1 t1.clock_date >= date_sub(date_sub(curdate(), interval  weekday(curdate()) day),interval 15 day)  , t1.clock_date < date_sub(curdate(),interval dayofweek(curdate()) + 6 day)  group clock_date 

the result :

enter image description here

now, want subtract 1 hour time spent using date_sub didn't work.

as mirkobrankovic wrote:

((timediff((select clock_time aura_clock t  t.clock_date = t1.clock_date , t.clock_time > t1.clock_time  order t.clock_time limit 1), min(clock_time))) - interval 1 hour) new_spent 

should work

edit:

the best got time in seconds : http://sqlfiddle.com/#!2/18160/66/0

a lot depends on mysql version


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -