I ran across a slight problem with a variable declared as a date.
I am checking in a loop through many of database records that three dates are within a certain pattern for a number of different records.
The time/date fields are read from 3 consecutive records into Date/time declared variables PreviousDate, CurrentDate and NextDate
Some records may have dates in some of them and some may not because there may not be 3 records.
When the three dates are equally spaced then the activity is regular.
When say the previous record hasn't been entered the Current Date is the first occasion
When say the last record isn't entered the current activity is the last to happen.
The problem is how to set each Date variable to effectively zero so when the datetime comparison is done each time in the loop it just doesn't think one of the variables is Midnight or belonging to a record in the previous step in the loop and make a wrong calculation.
I find that presetting say PreviousDate = 2 each step of the loop sets it to 1/1/1900 then if I include
If PreviousDate > 2 Then .... before the date comparison step, it works.
IsDate(PreviousDate) always returns true
Is there a more correct or elegant way of effectively "resetting" a date variable to a value that cant be confused with a current date?
I am checking in a loop through many of database records that three dates are within a certain pattern for a number of different records.
The time/date fields are read from 3 consecutive records into Date/time declared variables PreviousDate, CurrentDate and NextDate
Some records may have dates in some of them and some may not because there may not be 3 records.
When the three dates are equally spaced then the activity is regular.
When say the previous record hasn't been entered the Current Date is the first occasion
When say the last record isn't entered the current activity is the last to happen.
The problem is how to set each Date variable to effectively zero so when the datetime comparison is done each time in the loop it just doesn't think one of the variables is Midnight or belonging to a record in the previous step in the loop and make a wrong calculation.
I find that presetting say PreviousDate = 2 each step of the loop sets it to 1/1/1900 then if I include
If PreviousDate > 2 Then .... before the date comparison step, it works.
IsDate(PreviousDate) always returns true
Is there a more correct or elegant way of effectively "resetting" a date variable to a value that cant be confused with a current date?