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

  1. Newsgroups: comp.databases
  2. Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!dell32.ortta.umn.edu!durai
  3. From: durai@ortta.umn.edu (Durai Venkatasubramanian)
  4. Subject: Re: Pls help: algorithm wanted (xbase, pref foxpro)
  5. Message-ID: <durai.104.725756985@ortta.umn.edu>
  6. Lines: 103
  7. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  8. Nntp-Posting-Host: dell32.ortta.umn.edu
  9. Organization: U of Mn
  10. References: <durai.102.725742702@ortta.umn.edu> <1992Dec30.214031.25907@almserv.uucp>
  11. Date: Wed, 30 Dec 1992 23:09:45 GMT
  12. Lines: 103
  13.  
  14. In article <1992Dec30.214031.25907@almserv.uucp> g9utxu@fnma.COM (Tanin Uthayanaka) writes:
  15. >From: g9utxu@fnma.COM (Tanin Uthayanaka)
  16. >Subject: Re: Pls help: algorithm wanted (xbase, pref foxpro)
  17. >Date: Wed, 30 Dec 1992 21:40:31 GMT
  18.  
  19. >I will attempt to help.
  20. >
  21. >First, I'm assuming that you have a rate database (lets call it RATE.DBF) with the 
  22. >folowing field:
  23. >
  24. >    1 RATE
  25. >    2 START_DATE
  26. >    3 END_DATE
  27. >    4 STATUS
  28. >
  29. >Second, the user enters dStart and dEnd
  30. >
  31. >Third, the program would do the following:
  32. >
  33. >@ 10,10 SAY "Subcontract Period: "+DTOC(dStart)+" - "+DTOC(dEnd)
  34. >@ 11,0  SAY ""
  35. >USE RATE
  36. >INDEX ON START_DATE TO START
  37. >SET SOFTSEEK ON
  38. >SEEK dStart
  39. >IF ! EOF()
  40. >   IF dStart < RATE->START_DATE
  41. >      @ ROW()+1,15 SAY DTOC(dStart)+"CLEAR ALL
  42. >      @ ROW(),  30 SAY "Uncovered"
  43. >   ENDIF
  44. >   DO WHILE RATE->START_DATE >= dStart
  45. >      IF RATE->END_DATE <= dEnd
  46. >         @ ROW()+1,15 SAY DTOC(RATE->START_DATE)+" - "+DTOC(RATE->END_DATE)
  47. >         @ ROW(),  30 SAY RATE->STATUS
  48. >      ELSE
  49. >         @ ROW()+1,15 SAY DTOC(RATE->END_DATE+1)+" - "+DTOC(dEnd)
  50. >         @ ROW(),  30 SAY "Uncovered"
  51. >         EXIT
  52. >      ENDIF
  53. >      SKIP +1
  54. >      IF EOF()
  55. >         SKIP -1
  56. >         @ ROW()+1,15 SAY DTOC(RATE->END_DATE+1)+" - "+DTOC(dEnd)
  57. >         @ ROW(),  30 SAY "Uncovered"
  58. >         EXIT
  59. >      ENDIF
  60. >   ENDDO
  61. >ELSE
  62. >   @ ROW()+1,15 SAY DTOC(dStart)+" - "+DTOC(dEnd)
  63. >   @ ROW(),  30 SAY "Uncovered"
  64. >ENDIF
  65. >SET SOFTSEEK OFF
  66. >SET INDEX TO
  67. >USE
  68. >
  69. >Hope this helps, I know it's hard coded but the algorithm is there.
  70. >
  71. >TU
  72. >
  73. >P.S. Hope there's no bug I took only 10 minutes to write the code and didn't have 
  74. >     time to run the program
  75.  
  76.  
  77. Thanks for responding.  
  78.  
  79. The program did not work.  I tried with the following data.
  80.  
  81. Rate.dbf                    program variables
  82.  
  83. stdate    enddate           sdate: 01/01/92
  84. 07/01/91  06/30/92          edate: 12/31/93
  85. 07/01/92  06/30/93
  86.  
  87. The program rejected the entire period as "uncovered", whereas the results 
  88. should have been:
  89.  
  90. 01/01/92 - 06/30/93  :covered
  91. 07/01/93 - 12/31/93  :uncovered
  92.  
  93. The program statements,
  94.    IF dStart < RATE->START_DATE
  95.       @ ROW()+1,15 SAY DTOC(dStart)+" - "+DTOC(RATE->START_DATE-1)
  96.       @ ROW(),  30 SAY "Uncovered"
  97.    ENDIF
  98.    DO WHILE RATE->START_DATE >= dStart
  99. if i am not wrong, do the same thing, or do different things for the same 
  100. condition.  You are prompting an action if dstart<rate.startdate, and again 
  101. if rate.startdate > dstart.  However, the problem does not lie here.
  102.  
  103. My problem is to compare part of date range for each record.  It is possible 
  104. to pull all the records that cover the entire contract period.  Once that is 
  105. done, how do we map part of the contract period, the starting period of 
  106. which can be older than agreement start date and the ending period later 
  107. than the agreement end date.  For example, if the contract period is 
  108. 01/01/92 to 12/31/94, how do i check for, say, 01/01/93 - 12/31/93 ?
  109.  
  110. Somehow, the situation seems to be very basic to me (i am tempted to defend 
  111. my ignorance here, but the fact exists), and many of us would have dealt 
  112. with similar requirements.  I was wondering if anybody had a readymade 
  113. solution to this.
  114.  
  115. Thanks, anyway, for your time and effort.
  116.  
  117.