For MYSQL:du kan bruge date_add
:
SELECT * FROM ratepersqft
WHERE date < Now() and date > DATE_ADD(Now(), INTERVAL- 6 MONTH);
For SQL Server:, dateadd
:
SELECT * FROM ratepersqft
WHERE date < Now() and date > DATEADD(Month, -6, Now());
http://www.sqlfiddle.com/#!2/1f8029/48
**Indbryd venligst dit datokolonnenavn med backticks, da det er et reserveret nøgleord. **
MYSQL-opdatering:
SELECT *
FROM ratepersqft
WHERE date_format(date,'%Y-%m') <
date_format(now(),'%Y-%m')
and date_format(date,'%Y-%m') >=
date_format(now() - interval 6 month,'%Y-%m')
order by date desc;