I am trying to build a query that will load records from and to specific date comparing 2 fields - the start_time and the end_date.
SELECT start_time
,end_time
,DATEDIFF(end_time, start_time) AS DiffDate
FROM my_tbl
WHERE start_time >= '2015-04-27 00:00:00'
AND end_time <= '2015-04-28 00:00:00'
AND end_time >= '2015-04-27 00:00:00'
AND DiffDate < 100
LIMIT 1000;
Unfortunately the DiffDate returns always 0. The ideal scenario was to calculate the difference between start_time and end_time when inserting the end_time but the I cant make any changes on the database. What am I doing wrong here? Even if the DiffDate was working will it considered as a good solution?