× 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.




On 04/10/2005, at 7:16 AM, Goodbar, Loyd (ETS - Water Valley) wrote:

The issue I have is that in command/program CPP environments (CLP, RPG,
etc.), I am assured the command processor presents the date to the CPP in a
consistent, known, format.

The CL command CVTDAT depends on you knowing the date format going in. I'm
not guaranteed that.

As REXX receives the command line parameters "as typed", no date
presentation conversion has taken place. I don't know, for example, if
'100305' meant 3 October 2005 (mdy), 10 March 2005 (dmy), or 5 March 2010 (ymd). I can use the date format from the job or system settings and make some assumptions. It's really nice that OS/400 performs the work for me and
presents the date in a known manner - '1051003', 3 October 2005.

I think for now I will wrap the REXX procedure in a CL.

Stop making this so hard for yourself. You know a number of things:
1) The Command Analyzer requires DATE values to be entered in the format of the job
        2) The Command Analyzer passes the date to Rexx as typed by the user
        3) Rexx can invoke CL commands
        4) The CL command CVTDAT can convert from one date format to another.
        5) The CVTDAT command defaults to FROMFMT(*JOB) which matches item 1
6) The CVTDAT command help says it ignores input separator characters which solves item 2

So very simple Rexx code can be used to handle the date regardless of input format. For example:

The command definition:
REXXDATE:   CMD        PROMPT('Pass A Date To Rexx')

            PARM       KWD(DATE) TYPE(*DATE) MIN(1) PROMPT('A date +
                         ib job date format')                         

The Rexx processing program:
/* Rexx the Wonder Dog */
arg 'DATE('inDate')' .
toDate = '        '; /* Ensure enough room for output date */
say inDate;
'CVTDAT DATE('inDate') TOVAR(&toDate) FROMFMT(*JOB) TOFMT(*YYMD) TOSEP(*NONE)';
say toDate;
exit(0);

Running this via:
        REXXDATE DATE('31/12/99') 
or
        REXXDATE DATE(311299) 

results in:
        '31/12/99'
        19991231
        Press ENTER to end terminal session.

This will work regardless of the job date format.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.