The following is FoxProWin 2.6a code that I'm trying to use to reset a date field which is parsed into a table "Results1" from a vendor prioritary analyzer (which is not Y2K compliant and too expensive to update). I have been simply using:
REPLACE daterun1 with {01/01/2002} for daterun1={01/01/1902}
REPLACE daterun1 with {01/02/2002} for daterun1={01/02/1902}
etc, etc.
I am tired of this process and am trying to code a change, but the following code only replaces the field daterun1 with 00/00/00. I'm assuming it is using the value from the initial memvar setup from mdaterun1={}. What am I doing wrong? Thanks for your help!
* DateConv.prg DateConversion
* To reset the date/year 1900 to 2000 or 1901 to 2001 etc.
* Keeps day and month and only changes year.
* Table is "Results1.dbf" and field to change is Daterun1
*
SET CENTURY ON
USE Results1
mdaterun1={}
daterun1 = mdaterun1
DO WHILE NOT EOF()
IF (NOT EMPTY(daterun1)) and (daterun1 < CTOD("01/01/1940") ;
mdaterun1 = CTOD(LTRIM(STR(MONTH(daterun1))) + "/" + ;
LTRIM(STR(DAY(daterun1))) + "/" + ;
LTRIM(STR(YEAR(daterun1) - 1902 + 2002 )))
ENDIF
REPLACE Results1.daterun1 with mdaterun1
SKIP
ENDDO
*EndOfCode
REPLACE daterun1 with {01/01/2002} for daterun1={01/01/1902}
REPLACE daterun1 with {01/02/2002} for daterun1={01/02/1902}
etc, etc.
I am tired of this process and am trying to code a change, but the following code only replaces the field daterun1 with 00/00/00. I'm assuming it is using the value from the initial memvar setup from mdaterun1={}. What am I doing wrong? Thanks for your help!
* DateConv.prg DateConversion
* To reset the date/year 1900 to 2000 or 1901 to 2001 etc.
* Keeps day and month and only changes year.
* Table is "Results1.dbf" and field to change is Daterun1
*
SET CENTURY ON
USE Results1
mdaterun1={}
daterun1 = mdaterun1
DO WHILE NOT EOF()
IF (NOT EMPTY(daterun1)) and (daterun1 < CTOD("01/01/1940") ;
mdaterun1 = CTOD(LTRIM(STR(MONTH(daterun1))) + "/" + ;
LTRIM(STR(DAY(daterun1))) + "/" + ;
LTRIM(STR(YEAR(daterun1) - 1902 + 2002 )))
ENDIF
REPLACE Results1.daterun1 with mdaterun1
SKIP
ENDDO
*EndOfCode