How to check date field before MOVE EDITED in something like that:
IF #DATE NE 0
MOVE EDITED #DATE (EM=YYYY-MM-DD) TO #A10
END-IF
I get NAT1137 (Date is outside valid range. ) in line with MOVE EDITED.
How to check date field before MOVE EDITED in something like that:
IF #DATE NE 0
MOVE EDITED #DATE (EM=YYYY-MM-DD) TO #A10
END-IF
I get NAT1137 (Date is outside valid range. ) in line with MOVE EDITED.
I can recommend using the MASK option
See “MASK option” and “Checking dates” in the documentation under
“logical condition criteria”.
Finn
thanks very much
There is also a compiler option (MASKCME) that you might want to look at. It makes the MASK test compatible with the MOVE EDITED statement.
Enter COMPOPT at a prompt to see the compiler options.
steve
Hi, I´m a new member. Excuse me for my bad English.
I can recomended using the MASK option with follow example:
IF #DATE EQ MASK (19-20YYMMDD)
MOVE EDITED #DATE TO #A10
END-IF
The MOVE EDITED statement is not avaliable with date less than 1900
This is incorrect. MOVE EDITED works for dates in the year range 1571-2699. (or is it 1572? I never remember).
See following program and output
define data local
1 #date (d)
1 #a (a10)
end-define
*
move edited ‘17000214’ to #date (em=yyyymmdd)
*
move edited #date (em=yyyy-mm-dd) to #a
write 5T ‘=’ #a
end
PAGE # 1 DATE: 09-07-30
PROGRAM: DATETEMP LIBRARY: CALENDAR
#A: 1700-02-14
Sorry, That’s ok. The MOVE EDITED statement is not avaliable with date less than 1582. I think that a good date check could be:
IF #DATE EQ MASK (16-20YYMMDD)
MOVE EDITED #DATE (EM=YYYY/MM/DD) TO #A10
END-IF
However, I always use the check following because I don´t think that a date less than 1900 is all correct.
IF #DATE EQ MASK (19-20YYMMDD)
MOVE EDITED #DATE (EM=YYYY/MM/DD) TO #A10
END-IF
I wouldn’t use such a “combined” edit mask (with numbers and letters). There are problems with some leap years.
Example:
define data local
01 #date (a8 )
01 #a10 (A10)
end-define
#date := "19000229" /* 1900 was not a leap year!
IF #DATE EQ MASK (19-20YYMMDD)
write 'mask 19-20YYMMDD says: valid'
else
write 'mask 19-20YYMMDD says: invalid'
END-IF
IF #DATE EQ MASK (YYYYMMDD)
write 'mask YYYYMMDD says: valid'
else
write 'mask YYYYMMDD says: invalid'
END-IF
end
To clarify what Matthias is talking about, if you don’t specify the year in an edit mask check, Natural will use the current year for the check. If you only specify YY in the edit mask, Natural will use a century of its choosing (which century will depend on a session parameter). So, it is not a good idea to use combined masks. Instead, do two separate checks:
IF #DATE-CYMD NE MASK (YYYYMMDD)
WRITE 'INVALID DATE'
END-IF
IF #DATE-CYMD NE MASK (19-20......)
WRITE 'DATE IS NOT BETWEEN 1900 AND 2099'
END-IF