× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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, To be accepted for RPG date bifs/opcodes. So far they have not z-sup the 2 digit year.
I was disapointed that the opcodes could not expand the numbers in dates that had a divider, but I'm over it.
I will have to investigate the CEE part, I claim ignorance.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.