title: DATE lookup table (1990/01/01:2041/12/31)
body: <p>I use a DATE's master table for looking up dates and other values in order to control several events, intervals and calculations within my app. It has rows for every single day begining from 01/01/1990 to 12/31/2041. </p>
  
  <p>One example of how I use this lookup table is: </p>
  
  <ol>
  <li>A customer pawned an item on: JAN-31-2010 </li>
  <li>Customer returns on MAY-03-2010 to make an interest pymt to avoid forfeiting the item. </li>
  <li>If he pays 1 months interest, the employee enters a "1" and the app looks-up the pawn<br>
  date (JAN-31-2010) in date master table and puts FEB-28-2010 in the applicable interest 
  pymt date. FEB-28 is returned because FEB-31's dont exist! If 2010 were a leap-year, it 
  would've returned FEB-29.</li>
  <li>If customer pays 2 months, MAR-31-2010 is returned. 3 months, APR-30... If customer 
  pays more than 3 months or another period not covered by the date lookup table, 
  employee manually enters the applicable date. </li>
  </ol>
  
  <p>Here's what the date lookup table looks like: </p>
  
  <hr>
  
  <pre><code>{ Copyright 1990:2010, Frank Computer, Inc. }
  
  { DBDATE=YMD4- (correctly sorted for faster lookup) }
  
  CREATE TABLE     datemast 
  (
   dm_lookup       DATE,    {lookup col used for obtaining values below}
   dm_workday      CHAR(2), {NULL=Normal Working Date,}
                            {NW=National Holiday(Working Date),}
                            {NN=National Holiday(Non-Working Date),}
                            {NH=National Holiday(Half-Day Working Date),}
                            {CN=Company Proclamated(Non-Working Date),}
                            {CH=Company Proclamated(Half-Day Working Date)}
  
   {several other columns omitted}
  
   dm_description CHAR(30), {NULL, holiday description or any comments}
   dm_day_num     SMALLINT, {number of elapsed days since begining of year}
   dm_days_left   SMALLINT, (number of remaining days until end of year}
  
   dm_plus1_mth   DATE,     {plus 1 month from lookup date}
   dm_plus2_mth   DATE,     {plus 2 months from lookup date}
   dm_plus3_mth   DATE,     {plus 3 months from lookup date}
   dm_fy_begins   DATE,     {fiscal year begins on for lookup date}
   dm_fy_ends     DATE,     {fiscal year ends on for lookup date}
   dm_qtr_begins  DATE,     {quarter begins on for lookup date}
   dm_qtr_ends    DATE,     {quarter ends on for lookup date}
   dm_mth_begins  DATE,     {month begins on for lookup date}
   dm_mth_ends    DATE,     {month ends on for lookup date}
   dm_wk_begins   DATE,     {week begins on for lookup date}
   dm_wk_ends     DATE,     {week ends on for lookup date}
  
   {several other columns omitted}
  )
  IN "S:\PAWNSHOP.DBS\DATEMAST"; 
  </code></pre>
  
  <p>Is there a better way of doing this or is it a cool method?</p>