|
Thanks Scott,
Looks like thats where I'm headed.
Oh wait, I'm upgrading to 6.1, my worries are over. ;)
rpg400-l@xxxxxxxxxxxxxxxx 12/17/2009 3:36:33 PM >>>
FWIW, my solution to this problem was to write a subprocedure, and put
it into our "common utilities" service program. The pseudo code (off
the top of my head) to this subprocedure is as follows:
1) %scan for -. If found, this is the date sep.
2) if not -, %scan for /, if found this is the date sep.
3) if not either - or /, assume there's no date sep.
4) if no date sep, and the input string <6 chars long, pad it to 6 chars
by adding zeros to the left. Then %subst into MMDDYY
5) if no date sep and the input string <8 chars long, but >6 chars, pad
it to 8 chars by adding zeros to the left, then %subst into MMDDYYYY
6) if there's a date sep, then use the date sep to break into 3 fields,
M, D and Y. (This is done with the %scan and %subst BIFs)
7) At this point, no matter what the input, the data should be split
into an M, D and Y field. If Y<100, add 2000 to it.
8) Concatenate the M, D and Y fields (left padding each with zeros where
needed) to make a YYYY-MM-DD field.
9) Convert to a date field, and return the date field.
The idea here is that user can type 1/5/9 or 01/5/9 or 1/05/09 or
whatever they like, and it'll do it's best to figure it out as a date
field. Since our users all live in the USA, and all grew up with MDY
dates, we assume the date is in MDY sequence.
If I had wanted this to be universal, I would've passed an extra
parameter to the routine to indicate whether MDY, DMY or YMD was the
appropriate sequence for the month/day/year fields, but in my shop
that's not needed.
But the point is... it separates the fields into their month, day and
year components based on the date separators rather than forcing them to
be in a specific position, so the user doesn't have to zero-fill things.
I use this in all of my web applications, and occasionally even in
green-screen apps so give the user more flexibility on how they enter
dates. Once it's been converted to a date field, I can easily use it
with any of the RPG BIFS, etc, to get it into other formats when needed.
Buddy McClean wrote:
Thanks,2 digit year.
To be accepted for RPG date bifs/opcodes. So far they have not z-sup the
I was disapointed that the opcodes could not expand the numbers in datesthat had a divider, but I'm over it.
--
I will have to investigate the CEE part, I claim ignorance.
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.