title: Date split-up based on Fiscal Year
body: <p>Given a <em>From Date</em>, <em>To Date</em> and a <em>Fiscal Year system</em>, I want to get all the split-up duration within the
  given From &amp; To Date based on the Fiscal Year system.  Explained below with examples:</p>
  
  <p><strong>Example 1:</strong>
  Fiscal Year system: Apr to Mar</p>
  
  <p>From Date: Jan-05-2008
  To Date: May-15-2008</p>
  
  <p>Based on Fiscal Year system, duration should be splitted into: </p>
  
  <pre><code>Jan-05-2008 to Mar-31-2008
  Apr-01-2008 to May-15-2008
  </code></pre>
  
  <p><strong>Example 2:</strong>
  Fiscal Year system: Apr to Mar</p>
  
  <p>From Date: Jan-17-2008
  To Date: May-20-2009</p>
  
  <p>Based on Fiscal Year system, duration should be splitted into:</p>
  
  <pre><code>Jan-17-2008 to Mar-31-2008
  Apr-01-2008 to Mar-31-2009
  Apr-01-2009 to May-20-2009
  </code></pre>
  
  <p>Am looking for approach/algorithm to solve this in PostgreSQL 8.2.</p>
  
  <p>Regards,</p>
  
  <p>Gnanam</p>