I'm wondering how to use a variable in a SELECT statement to load data from any month from my SQL server! Currently I have this (the below code), which loads the currently passed month! Is there a way to say that timespan minus 1 month? or 2 months? and then have that negative month number as a variable to use with AJAX? To for instance load 3 months back in time or when you want 4 months back in time, and so on!? It is important that the latest month is from now and one month back in time, and the variable the same time minus the months typed in!
SELECT hrs, snitt_fukt, max_fukt, min_fukt
FROM `testingf`
where hrs between date_sub(now(),INTERVAL 1 MONTH) and now();