You will need to adjust the start, or end, dates before making your query. If the start date is outside the range of the available data-days: 1. if it's before the first day, then return #n data-days beginning on the first day ... or return an error. 2. if it's after the last day, then return the last #n data-days from the data ... or throw an error. 3. if the start date is in the valid range, but the user wants more data-days than are possible, decrease the start date so you can return the required data-days data. You don't specify how exactly, given valid start and end dates you let the user choose which 30,60,90 day chunk to return, so can't comment on that.
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009