You need to create a date range for your query. What the query itself looks like is entirely dependent on what your data source is going to be. (i.e. sql, excel file, text file???). If your user picks a date and you want to calculate the date 3 months previous, then you just need to do the following:
DateTime startDate = userDate.AddMonths( -3 );