PDA

View Full Version : Date Fields



Guest.Visitor
01-01-1995, 02:00 AM
An RPG4 question.... I'm rather new to 4, having only really worked in 400. I have to compare the date on file which is 8 long in YYYYMMDD format to the current date. Which date format can I use, or do date fields have to be 10 long? *ISO has a "no separators" option, but it's still 10 long. Thanks Kate

bibarnes@yahoo.com
09-29-2000, 05:39 AM
In ILE the date field types can be compared to one another regardless of the format. You can't compare a non-date field to a date field. You can move that yyyymmdd to a date field though. C *ISO MOVE yyyymmdd Datefld It doesn't matter what format datefld is. I hope I didn't confuse you. Hope This Helps

Guest.Visitor
09-29-2000, 05:49 AM
Try this out. I'm sure someone can come up with something a little slicker, but this is what you want to do. <pre> h DatFmt(*ISO) fFile if e disk d yyyy_mm_dd s d DatFmt(*ISO) d Today s d DatFmt(*ISO) c move *Date Today c read File c if not %eof c *ISO0 test(d e) FileDate c if not %error c *ISO0 move FileDate yyyy_mm_dd c else c** Invalid date c endif c if yyyy_mm_dd <> Today c** Do something c endif c endif c eval *inlr = *on </pre>

Guest.Visitor
09-29-2000, 06:25 AM
Mike, I would use TIME into your *ISO date field instead of *DATE to get the current date. *DATE is dependent on the job date format. You can also initialize a date field with *SYS to get the current date. <pre>D Today s d Inz(*Sys) C Time Today</pre> Oops, now that I think about it, your logic will work fine. Never mind! Chris

Guest.Visitor
09-29-2000, 06:40 AM
Darn you Chris, you always know how to get rid of a couple lines of my code!

Guest.Visitor
09-29-2000, 10:20 AM
Chris, *DATE isn't dependent on the job date format. It's dependent on the DATEDIT keyword format. But either way, as you say, Mike's code will work fine. (Except prior to V3R7, you'd need to code the right format on the MOVE from *DATE.) Katy, you should use MOVE *DATE (or INZ(*JOB)) if you want the job date, and use the TIME opcode (or INZ(*SYS)) if you want the system date. (But you probably already knew how to get "today" since you were only asking about the 8-digit variable date ...) Barbara Morris