In message <[EMAIL PROTECTED]>
, Gordon Stewart <[EMAIL PROTECTED]> writes
>Hi there,
>
>I have a database set up, with one of the fields is a month -
>
>"200611" = November 2006
>"200610" = October 2006
>"200609" = September 2006
>
>I was wondering, I know how to sort descending etc.. - Is there a way,
>to (add to an existing search criteria).. select all records in the
>last XX months..

>
>
>IE, If I only wanted the last 2 months, it will only select records in
>October & November 2006....

...WHERE monthfield > "200609"

or, if you want to pass the number of months in
...WHERE monthfield > DATE_FORMAT(date_add(now(), interval -2 month),
'%Y%m');

-- 
Pete Clark

Sunny Andalucia
http://www.hotcosta.com/comm_1.htm

Reply via email to