tags:

views:

29

answers:

1

I am trying to write a query where I can eliminate a timediff of less than 2 minutes. I have tried variations on the following which returns no results

 timediff(sessions.producer_on,sessions.producer_off)>'00:02:00'

the timediff without the > works fine and returns all results - I am having difficulty with the >00:02:00 condition. Can anyone help - many thanks

+1  A: 

You need to extract the minute from the time then compare it.

minute(timediff(sessions.producer_on,sessions.producer_off)) > 2 AND 
hour(timediff(sessions.producer_on,sessions.producer_off)) = 0

Also it may be necessary to make sure that the hour is 0 since only when the hour is zero does the minute actually matter.

Vincent Ramdhanie
nice one - works perfectly - many thanks
al
No Problem. Glad to help.
Vincent Ramdhanie