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!

ADDDUR

Status
Not open for further replies.

LUEBBKEVIN

Programmer
Apr 30, 2002
35
US
I don't remember if there is a conversion method in RPG or not (the mind is going fast)

I have a field in a file defined
END DATE IADEND P 8 0
data formatted as ccyymmdd
In my program I load this field to a work field that is defined as:

D @H_ENDDATE S Like(ENDDATE)

I also created another work field for the duration:
D @H_DURATION S Like(ENDDATE)

In the program the @H_ENDDATE field is loaded with
the value in the data file END DATE
The @H_ENDDATE is copied to @H_DURATION
EVAL @H_DURATION = H_ENDDATE
The ADDDUR function is run over the @H_DURATION
ADDDUR 1:*DAYS @H_DURATION

on the compile I get
*RNF7261 30 134919 The Result-Field operand @H_DURATION is not valid for the
specified operation.

can't find much on the function to know what format restrictions exist.
 
Use the data type of D. This will define the field as a date field. I believe you need this format for both dates. Mike Wills
AS400 Programmer
[pc2]

Please, if you find my post useful, let me know. [thumbsup2]
 
If you are starting with a date held as a numeric 8,0 field, you need to define a Date workfield of type D, as Mike says above, then

*ISO Move H_ENDDATE WorkField
AddDur 1:*D WorkField

I'm using *ISO because your date seems to be held as yyyymmdd but you can use *CYMD, *EUR, *DMY etc depending on the format of the numeric field. If you then need to move it back to a numeric field so that you can compare it against other fields in your database you just need

*ISO Move WorkField WorkField2

The second workfield is defined as a numeric 8,0 field
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top