title: How to store calendar app data in SQL Server 2005
body: <p>I'm creating an online Calendar app (like Google Calendar or MS Outlook), and <strong>not sure how I should store the data</strong> to make it fast to query for the basic views: Daily, Weekly, Monthly.</p>
  
  <p>Before you mark this as a duplicate, please keep in mind I have read several threads here and in most cases they say "too hard to optimize for general purposes".  In my case this is a very specific purpose that I haven't seen asked about yet -- a very specific type of data which many developers have [hopefully] had experience with.</p>
  
  <p>I need to quickly get any rows that land inside my view (day, week, month), so something like:</p>
  
  <pre><code>[end date of row] &gt;= [start date of query]
  AND
  [start date of row] &lt;= [end date of query]
  </code></pre>
  
  <p>I don't see a normal b-tree index working well for this, but I also suspect someone has figured out something clever that will work with SQL Server 2005 (and probably older), since calendar apps have been around forever, and there are 100s of them.</p>
  
  <p>I'm also curious about reoccurring events, how to store those, although my current plan is to just always read all of those (index by "Is Recurring") and optimize that in code, and not SQL. There shouldn't be a huge number of those, unlike normal events which could get very large over time.</p>
  
  <p><strong>Update</strong>: Also unique to this question, because it is for a calendar app, I need to store dates with timezone info, but my queries cannot be timezone specific.  If you have experience with a Calendar app, you'll know what I mean (if not, you'll just say store as UTC).</p>