Can someone please give me example code in RPG IV how to do the simple task of converting a 8 digit numeric field in YYYMMDD format to a 6 digit field in MMDDYY format. My desired result is to display the date as MM/DD/YY. I am using the ISO format but am coming up with zeros in my result field. Please help.
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
Convert Date
Collapse
X
-
Convert Date
Joe, it still doesn't work. Something strange is going on here. Here is my code: FEDCMON IF E DISK * D workdate S D c read edcmon 10 c *ISO move eddate workdate c *MDY move workdate mmddyy 6 0 c z-add 1 x 1 0 c move *ON *INLR When I put it in step by step debug, Eddate (data base file) = 20000703. After the workdate line is executed. It's value is '001-01-01' When the mmddyy line is executed, it then steps to the *INLR line (skipping Z-add 1 to X). When I show variables at LR, it shows mmddyy = '000000' and X= 0. Any idea what is wrong? Thanks. Ron For some reason
Comment
-
Convert Date
A couple of questions. When you say that eddate = 20000703, is that as seen in debug, or what you know is on the file? What is the value of indicator 10 when after the read? From previous threads, for workdate to have the value you specify, it means that the value you are moving to it is not a valid date and is probably zero. That is why I suspect the value of eddate. Are you certain that eddate is 8/0? Russell
Comment
-
Convert Date
Yes may 8 numeric data field is 20000713. I tried changing *ISO to *ISO0 but got a compile error. 0072.00 c *ISO0 move eddate workdate The Date, Time, or Timestamp separator '0' is not allowed with numeric entry EDDATE. Indicator 10 is off so the file is being read and it is retrieving the correct numeric value in eddate 20000713. ron
Comment
-
Convert Date
Ron, What is your program definition of the field eddate? 8s0 or 8p0? Looks to me like it is 7s0 and that's the wrong length for an *iso numeric date and would explain why your *ISO native date field contains '000' instead of '2000' as the year. Is eddate really a *CYMD date? And, you would only need the zero in *iso0 if eddate is char 8a (a character field without without the '/' separators) instead of 8s0. Chris
Comment
-
Convert Date
Dave, I still can't get it to work using your or Joe's example. When I use your example, I get a value of 01/01/40 in workdate. When in debug, it skips the 'z-add 1 x' line and goes to LR. I am sure I have recompiled the source. My eddate field is not defined in the program, it is a database file that is Packed, length of 8, zero decimals. FEDCMON IF E DISK * D workdate S D datfmt(*MDY) c read edcmon 10 c *ISO move eddate workdate c z-add 1 x 1 0 c move *ON *INLR
Comment
-
Convert Date
FEDCMON IF E DISK * D workdate S D datfmt(*MDY) c read edcmon 10 c *ISO move eddate workdate c z-add 1 x 1 0 c move *ON *INLR --------- In this program, put a breakpoint on the first "move" (the one that moves eddate into workdate) and show view the contents of the following: *IN10 eddate workdate Then step to the next line. Tell us what line you are on. Show us the contents of the three fields again. Show us your joblog. Joe
Comment
Comment