Similar to the question at MYSQL: Find Start and End Timestamp of a consecutive count, I have a table with similar data:
StatusTime | Reading 2014-01-01 0
Try this code:
select *
(select max(StatusTime) from tbl where Reading > 50) above_50,
(select min(StatusTime) from tbl where Reading < 50) bellow_50;
Something like this?
SELECT DISTINCT MAX(StatusTime), MIN(StatusTime)
FROM table_name
WHERE Reading < 50 OR Reading > 50;
If it only goes below/above again once per day, you can make the query quite simple; just find the min and max time where it's below, grouping by date.
SELECT
DATE(statustime) statusdate,
MIN(CASE WHEN reading<50 THEN statustime ELSE NULL END) start_time,
MAX(CASE WHEN reading<50 THEN statustime ELSE NULL END) end_time
FROM myTable
GROUP BY statusdate
An SQLfiddle to test with.