[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re[2]: Date Comparison Problem




     Thanks for the reply. I did try an IF, with the same result. If I
     could look at the internal format, I would bet that the compares are
     something like 01-feb-1998 vs. 01-feb-1998 12:23:34 and the compare is
     rendered 'unpredictable'.

     Next thought is to just count the days because numerics from dates
     appear to work OK for me. #MaxDaysInReport=365 then decrement with an
     if until #DaysTilNextEvent > #MaxDaysInReport.


______________________________ Reply Separator _________________________________
Subject: Re: Date Comparison Problem
Author:  "sam spritzer" <sspritzer@gw.ctg.com> at internet
Date:    4/23/1999 7:21 AM


Have you tried using IF instead of WHILE?  I have had similar problems with WHIL
E...it just kind of runs amok even with a BREAK statement.
Hope this helps and thanks for the insight in the email generator,
Sam

<<< Richard Mitchell <richard.mitchell@GSA.GOV>  4/22  1:15p >>>

     SQR4
     NT
     ORACLE 8
     READ THE MANUAL = YES (can't wait for the new book due out)

     Desire: Calculate a 'next due' and compare it to the last possible
     date. Stop when the new date is greater than the last date.

     Problem: The compare is never NextDate > Last Possible date

     The dates printed go way beyond the EndDate Specified. The code stops
     using the generic counter I installed. The "dates" printed show dates
     that "look" correct, but the while is never satisfied.

     My code is not good as this is a first attempt at array processing and
     date processing to this extent.

     Any help regards getting the While to terminate would be appreciated.

     TIA,

     Rick

     <Snip>

     DECLARE-VARIABLE
         DATE    $200-NextDue
         DATE    $200-LastNextdue
         DATE    $Date1 ! Temporary date holders
         DATE    $Date2
         DATE    $Date3
         DATE    $Date4
         DATE    $Date5
         DATE    $Date6
     END-DECLARE

     ...

     Begin-Procedure 200-DetermineNumberOfEntriesInTable
     !Save the next due, Frequency
     Get $JPJPDURATION $PMFREQUENCY $PMNEXTDATE $PMMONTH From
     PMScheduleArray(#_ArraySubscript) JPJPDURATION PMFREQUENCY PMNEXTDATE
     PMMONTH

         Let #EvJPDuration     = to_number($JPJPDURATION)
         Let $MonthNumber      = $PMMonth
         Let #MonthNumber      = to_Number($MonthNumber)
         Let #MonthNumber      = #MonthNumber   1
         Let $Date1            = $PMNEXTDATE
         Let $200-NextDue      = $PMNEXTDATE

         Let $200-LastNextDue  = dateadd($Date1, 'day' , 364)
         Let #200-Frequency    = to_Number($PMFREQUENCY)

         print $200-NextDue      ( 1,1)
         print #200-Frequency    ( 1,1)
         print $200-LastNextdue  ( 1,1)

        While ($200-NextDue <= $200-LastNextdue) or (#_LockUp <  365)
         Let #_lockUp = #_LockUp   1

     !   Add hours to Array(NextDue)
         Do 300-EvaluateMonth (#_ArraySubscript,#MonthNumber,#EvJPDuration)

     !   Add Frequency to the date giving NextDate
         Let $date1  = dateadd($200-NextDue, 'day' , #200-Frequency)
         Let $200-NextDue = $date1

     ! Diagnostic prints for debugging only

          Print $200-NextDue ( 1,1)
          Print '<=========' ()
          Print #200-Frequency (, 1)
          Print '<=========' ()
          Print #MonthNumber (, 1)
          Print '<=========' ()
          Print #EvJPDuration (, 1)
          Print '<=========' ()

        ! Get the new Month from NextDue incase work is due in a new month

         Let #MonthNumber  = to_Number(edit($200-NextDue,'MM'))

        End-While

     End-Procedure

     <Snip>