Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date question

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
I have an order entry screen. One of the fields is a Delivery Date. It is a date field with the format of MM/DD/YY including the slashes. The field name is DELDATE.

First Question:
Since it is a date field will the system automatically check that it's a valid date that the user has entered? If invalid , will the system pass errors to the screen, so I don't have to run any check's in my program?

Second Quesion:
In my program I want to make sure the user hasn't entered a date that has passed. Anything less than today's date.

Will this work

DCurDateTm S 12 0
DCurDate S 6 0

C time CurDateTm
C move CurDateTm CurDate
C if deldate <Curdate
C EVAL ERRIND =*ON
etc.

I'm not sure if the system still sees these as dates after the move command. Does the move command keep the date &quot;format&quot;?

Thanks in advance for any and all help.

 
Well where to begin.. Let me preface my responce by saying,, Fellow programmers,,, I did my last &quot;heavy programming&quot;, with RPGIII,,so if w/RPG IV,, it has changed correct me quicky,, so I can learn and see what has happened.

My first observation would be,, that you are not a programmer, evem though you are w/MIS, so now.

1. Just because the field is on the screen as a date, does not mean the &quot;system&quot;, will validate it as a date, most programmers, work hard at coming up, with date validation routines. They can and will vary with the programmer's experience. since this is already in a program,,, scan and look through the code until you find the validation routine. From the code example,,,you either are picking out code from the original data entry program,, and trying to modify it. I will let the RPGIV / FREEFORM, code poets deal with that question, but I would say it looks like a good beginning.

2. Something just hit me,, has this field always been a user entry field? If yes then there is somewhere in the code, a routine to validate it,, just look for that portion, and modify it. If not,,, then the syetem is generating the date,, and look for that routine.
 
1. I've only been programming RPG IV for about 6 months. So I don't consider myself an RPG programmer, YET. That's why I ask questions. I've been writing VB and VBA for 8 years so I do consider myself a programmer in that respect. So I believe your observation is incorrect.

2. I have no problem writing code to validate the date. In fact that what I was doing when it struck me that maybe since I was using a DATE field that they system might check to see if it's at least a VALID DATE so I wouldn't have to code that piece in this and future programs. I have never used a date field on a &quot;RPG display&quot; before. I still have to write code to validate other aspects of the date.

If anyone has experience with the date field (Code Designer)and knows the answer to the question that would be great. Until then I will continue to check if it's a valid date through code. Thank you.
 
I just spoke to a RPG programmer and he told me that YES the system will automatically check a DATE FIELD to see if a valid date has been entered.

Does anyone disagree?

 
If it does it automatically,,, I would be very interested to see the rpgIV code that does it.. This I have to add to my knowledge base..
 
The date field is in my display file and I haven't compiled it to check if what I was told is true.

I'm going to create a quick program to test the screen and date field. I'll get back to you with what I've found....unless someone beats me to it :)

 
I just tested it. There is no code necessary. If you use a date field on your display and you enter an invalid date a message displays &quot;field value is not an allowed date&quot;.

FYI

 
That's the real nice thing about RPG IV, it made using dates much easier, and much less coding required to validate the date field.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Hey RedMage! Yes that is a very nice feature! I have to say I was a bit insulted at first when it was assumed I wasn't a programmer based on my date questions. It seemed perfectly logical to me that if there is an option provided for a date field that the system would also validate the date. Like other languages. I like it when things are made easier.

Later....

 
I don't fully know what your background is. But I remember coding RPG III in school, and trying to determine if the date was valid, was it a leap year, etc. Much easier to code a date data type, and then let the system determine automatically (to me, anyway) if the date is valid. How do you like the other date operations?

RedMage1967
IBM Certifed - RPG IV Progammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top