[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Date Comparison Problem
- Subject: Date Comparison Problem
- From: Richard Mitchell <richard.mitchell@GSA.GOV>
- Date: Thu, 22 Apr 1999 13:15:00 -0400
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>