home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / database / 8732 < prev    next >
Encoding:
Text File  |  1992-12-30  |  3.8 KB  |  124 lines

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!almserv!mimas!g9utxu
  3. From: g9utxu@fnma.COM (Tanin Uthayanaka)
  4. Subject: Re: Pls help: algorithm wanted (xbase, pref foxpro)
  5. Message-ID: <1992Dec30.214031.25907@almserv.uucp>
  6. Sender: usenet@almserv.uucp
  7. Nntp-Posting-Host: mimas
  8. Reply-To: g9utxu@fnma.COM
  9. Organization: Fannie Mae
  10. References: <durai.102.725742702@ortta.umn.edu>
  11. Date: Wed, 30 Dec 1992 21:40:31 GMT
  12. Lines: 110
  13.  
  14. In article 725742702@ortta.umn.edu, durai@ortta.umn.edu (Durai Venkatasubramanian) writes:
  15. >I need an algorithm to accomplish a date comparison task.  Any help will be 
  16. >appreciated and gratefully remembered for life.
  17. >
  18. >I have an application that keeps track of subcontracts issued to outsiders.  
  19. >For every subcontract, we have to receive various rate agreements.  The 
  20. >subcontracts we issue usually span across multi years, but the rate 
  21. >agreement we receive is always for one year, and renewed every year for the 
  22. >duration of the contract.  The rate agreements can be provisional or 
  23. >final.  We should at least have a provisional agreement on file, in order 
  24. >to issue subcontract.  The rate agreement can be according the vendor's 
  25. >fiscal year.
  26. >
  27. >When the user enters the subcontract start and end dates, the system has to 
  28. >check the available rate agreements for the period, and summarize how the 
  29. >various rate agreements cover the subcontract.
  30. >
  31. >For example, I have a subcontract for the period 01/01/92 - 12/31/94 (3 
  32. >years).  I have the following rate agreements:
  33. >
  34. >Final  07/01/91 - 06/30/92
  35. >Final  07/01/92 - 06/30/93
  36. >Provl  07/01/93 - 12/31/93
  37. >Final  01/01/94 - 06/30/94    
  38. >    
  39. >The coverage report should look as follows:
  40. >
  41. >Subcontract Period: 01/01/92 - 12/31/94
  42. >
  43. >How Covered ?  
  44. >
  45. >01/01/92 - 06/30/92 Final 
  46. >07/01/92 - 06/30/93 Final
  47. >07/01/93 - 12/31/93 Provl
  48. >01/01/94 - 06/30/94 Final
  49. >07/01/94 - 12/31/94 Uncovered
  50. >
  51. >
  52. >My problem:
  53. >
  54. >I have all the individual agreements on a database.  When the user enters a 
  55. >new subcontract, the system compares the contract period with the agreement 
  56. >period to establish coverage or otherwise.  I am using foxpro, and a command 
  57. >line like "for between(contractdate, agreement_start_date, 
  58. >agreement_end_date)" or "for between(agreement_end_date, 
  59. >contract_start_date, contract_end_date)".  I am not getting the desired 
  60. >result.  How do I properly tabulate the results of the comparison ?  What am 
  61. >I doing wrong ?  
  62. >
  63. >I apologize if I am asking too much.  If someone has a solution for similar 
  64. >problem, and is willing to share, I will be very thankful.
  65. >
  66.  
  67.  
  68. I will attempt to help.
  69.  
  70. First, I'm assuming that you have a rate database (lets call it RATE.DBF) with the 
  71. folowing field:
  72.  
  73.     1 RATE
  74.     2 START_DATE
  75.     3 END_DATE
  76.     4 STATUS
  77.  
  78. Second, the user enters dStart and dEnd
  79.  
  80. Third, the program would do the following:
  81.  
  82. @ 10,10 SAY "Subcontract Period: "+DTOC(dStart)+" - "+DTOC(dEnd)
  83. @ 11,0  SAY ""
  84. USE RATE
  85. INDEX ON START_DATE TO START
  86. SET SOFTSEEK ON
  87. SEEK dStart
  88. IF ! EOF()
  89.    IF dStart < RATE->START_DATE
  90.       @ ROW()+1,15 SAY DTOC(dStart)+" - "+DTOC(RATE->START_DATE-1)
  91.       @ ROW(),  30 SAY "Uncovered"
  92.    ENDIF
  93.    DO WHILE RATE->START_DATE >= dStart
  94.       IF RATE->END_DATE <= dEnd
  95.          @ ROW()+1,15 SAY DTOC(RATE->START_DATE)+" - "+DTOC(RATE->END_DATE)
  96.          @ ROW(),  30 SAY RATE->STATUS
  97.       ELSE
  98.          @ ROW()+1,15 SAY DTOC(RATE->END_DATE+1)+" - "+DTOC(dEnd)
  99.          @ ROW(),  30 SAY "Uncovered"
  100.          EXIT
  101.       ENDIF
  102.       SKIP +1
  103.       IF EOF()
  104.          SKIP -1
  105.          @ ROW()+1,15 SAY DTOC(RATE->END_DATE+1)+" - "+DTOC(dEnd)
  106.          @ ROW(),  30 SAY "Uncovered"
  107.          EXIT
  108.       ENDIF
  109.    ENDDO
  110. ELSE
  111.    @ ROW()+1,15 SAY DTOC(dStart)+" - "+DTOC(dEnd)
  112.    @ ROW(),  30 SAY "Uncovered"
  113. ENDIF
  114. SET SOFTSEEK OFF
  115. SET INDEX TO
  116. USE
  117.  
  118. Hope this helps, I know it's hard coded but the algorithm is there.
  119.  
  120. TU
  121.  
  122. P.S. Hope there's no bug I took only 10 minutes to write the code and didn't have 
  123.      time to run the program
  124.