To compute the time between 2 dates is usually done by converting each date to it's Julian Day n(JD). The Julian day is the number of days since 1 January 4713 BC. Once you have the JDs for each date, then just subtract one from each other to get the number of days between the dates.
Google Julian Date calculations to read up on this approach.
The following is an example of how this is done in FORTRAN. I think that this can be translated to the TBASIC as used by the PLC fairly easily.
INTEGER FUNCTION JD (YEAR,MONTH,DAY)
C
C---COMPUTES THE JULIAN DATE (JD) GIVEN A GREGORIAN CALENDAR
C DATE (YEAR,MONTH,DAY).
C
INTEGER YEAR,MONTH,DAY,I,J,K
C
I= YEAR
J= MONTH
K= DAY
C
JD= K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) /12-3*((I+4900+(J-14)/12)/100)/4
C
RETURN
END
I have not translated this code to TBASIC to test it. If you do attempt to write code for JD calculations, then I would suggest that you break the calculation up in multiple statements and be very careful with the multiplication and division operators. Remember TBASIC only supports integer math (there are no fractions). If you divide 1/4 you won't get 0.25 you will get 0.
Gary D.