Sound a bit tricky.. So if I understand you are not looking for just going back say 90 days. You want to go back 3 months regardless of where you are in the current month?? If that is the case, then extract the current month and – 4 to get your new starting month.
Example: Dec is month 12 and you want all of Sept (9), Oct(10), Nov(11) as well as current data in Dec.
Then just string together the new month, year if it wraps around and starting day to one. Post your code if you have problems.
One more thing I forgot. For selecting the date ranges in a proper manner, you need to sort them by year/month/day before you set your range parameters.