Date Validation

reenageorge5

New Member
Hi,

I have to write a pgm to display the details of an item transaction

Item From:------ To:---------

Date From:--/--/- To:--/--/--
Output to:...............

this is the prompts for the same. if i enter dates like 31/02/07 it should display error....Also date entering format should be above given.Help me in the codig of this(date)....


Thanks........
 
you can do something like this.


once they enter it and you hit the choose event on that button do something like this.

using the screen value of the fillin or whatever.

this is just something off the top of my head to give you an idea.


isValid = true.

strDay = substring(fromdate:screen-value,1,2).
strMonth = substring(fromdate:screen-value,4,5).
stryear = substring(fromdate:screen-value,7,8). //2 digit year

if int(strDay) > 12 or int(strDay) < 1 then
isValid = false.
if int(strmonth) > 31 or int(strmonth) < 1 then
isValid = false.
if int(stryear) > 99 or int(stryear) < 0 then
isValid = false.

if isValid <> true.

Then do what you want it to do if it isn't valid.

thats more or so just a psuedo-style not actual syntax.
 
simpler code:

DATE(fromdate:screen-value) NO-ERROR.
IF ERROR-STATUS:ERROR THEN MESSAGE "Invalid date!" VIEW-AS ALERT-BOX ERROR.

You can also display the error message with:
MESSAGE ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX.
 
Back
Top