If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > timediff greater than some seconds

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-11, 14:44
franrtorres77 franrtorres77 is offline
Registered User
 
Join Date: Nov 2010
Posts: 7
timediff greater than some seconds

Hi there

I have a query that returns the diffrence time from two dates but I would like to get also in the same query those results that are greater that for example 300 seconds.

Here it is my query:

select truck, date,speed,heigh, timediff(@nexttime,date) as diffrence ,timestampdiff(second,date,@nexttime2) as seconds,
(@nexttime:=date) as Next,(@nexttime2:=date) as Next,x,y
from points
where truck=1883
and date>= '2011-05-21 00:00:00'
and date<= '2011-05-21 12:44:59'
order by date desc

What I get now is all the records with the "difference field" calculated but I can't get those greater than 300 seconds even using in the where clause:

timestampdiff(second,date,@nexttime2) > 300

thank you
Reply With Quote
  #2 (permalink)  
Old 05-26-11, 05:04
ashish_mat1979 ashish_mat1979 is offline
Registered User
 
Join Date: Aug 2005
Posts: 30
Try using Group By with Having clause.

Like:-
group by speed Having timestampdiff(second,date,@nexttime2) > 300
__________________
Ashish
Entertainment Overloaded
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On