I have a table in DB where there are two colums – ‘start’ and ‘end’, which are in DateTime format.
What i need is a fast query that will return me first (counting from now) that row, in which ‘end’ is smaller by at least 1 hour (start[1] – end[0] > 1h) than ‘start’ in the row below (as I am ordering by ‘start’). I was struggling it for ages and all i came up was empty returned list and it was very slow…
I have a table in DB where there are two colums – ‘start’ and
Share
Use DATEDIFF, if you are using MYSQL.
Refer: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html