I need the last month of recorded data, not the data from current date -1 month.
Here my wrong query:D
SELECT MIN(date(Timestamp)) as fDate , MAX(date(Timestamp)) as tDate FROM data WHERE boxid=45 AND
YEAR(Timestamp) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
AND MONTH(Timestamp) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)
EDIT: i have much data in my table, i just want to see where the last recoded data starts and where it ends, but i want the last month.
example , table has recoded till january 17th. i want now 2 dates: January 1st and 17th
I tried this
SELECT max(date(Timestamp)) as toDate, min(date(timestamp)) as fromDate FROM data WHERE timestamp<=(SELECT MAX(date(Timestamp)) FROM data )
AND timestamp>=(SELECT (MAX(date(Timestamp))- INTERVAL 1 MONTH) FROM data ) AND ID=10
it has a strange behavior , its giving me not 30 days...