Thanks for your response.
I am trying to move a DATE-data type to the most common file output format of YYYYMMDD.
For some reason when the output specifier is @Y%m%d (=YYYYMMDD), then COBOL is not able to use the MOVE verb to move it to an alpha field. (Works great for @Y/%m/%d).
Apparently the only solution is to use COMPUTE, which isnt consistent with ILE COBOL in that any other MOVE numeric to alpha works just fine.
COMPUTE works well, so I will use that.
It is frustrating that such a simple and common use - moving a date to a column - works fine with slashes, but fails and requires a work-around without slashes.
Every other OS & DB mgmt system handles this stuff consistently - at least the ones that are still around:)
Thanks again.
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx [mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of MichaelQuigley@xxxxxxxxxx
Sent: Thursday, November 29, 2012 8:02 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: Re: [COBOL400-L] how to extract the most common date format - YYYYMMDD
Hi Joel,
I just got the digest from the mailing list.  I use the date functions all 
the time--they are definitely not full of bugs.  We've found a couple of 
oddities, but IBM quickly provided fixes for these.
Let me see if I understand correctly.  Do I understand that what you want 
is to translate from a field containing (for example), "20121128" and end 
up with the format "2012-11-18"?
You can use EXTRACT-DATE-TIME, but I generally use CONVERT-DATE-TIME.  The 
EXTRACT function is intended to extract a portion of the date-time 
field--e.g., the month or the year.  If you simply are converting from one 
format to another, ILE COBOL handles all the work for you.  If you're 
confident that ws-date always contains a date, try the following:
move ws-date to A0468X-DUE-DATE of AFTR
This is using the following working-storage assumptions:
01 ws-date                     format date '@Y%m@d'.
01  AFTR.
    05  A0468X-DUE-DATE        format date '@Y-%m-%d'.
If ws-date is not defined in working-storage as a FORMAT DATE field, then 
you'll want to use the following:
move function CONVERT-DATE-TIME (ws-date DATE '@Y%m%d') to A0468X-DUE-DATE 
of AFTR.
This example uses the following working-storage assumptions:
01 ws-date                     pic 9(8).
01  AFTR.
    05  A0468X-DUE-DATE        format date '@Y-%m-%d'.
If this isn't what you have in mind, post another message with the formats 
of WS-DATE and A0468X-DUE-DATE.  I'm convinced there's nothing with dates 
that ILE COBOL can't handle.
Michael Quigley
Computer Services
The Way International
www.TheWay.org
419 753-1222
cobol400-l-bounces@xxxxxxxxxxxx wrote on 11/28/2012 04:53:57 PM:
----- Message from "Stone, Joel" <Joel.Stone@xxxxxxxxxx> on Wed, 28 
Nov 2012 19:57:32 +0000 -----
To:
"'COBOL Programming on the iSeries/AS400'" <cobol400-l@xxxxxxxxxxxx>
Subject:
Re: [COBOL400-L] how to extract the most common date format - YYYYMMDD
Thanks but here is IBM doc example from "Websphere Development 
Studio ILE COBOL reference" v5  SC09-2539-02:
MOVE FUNCTION EXTRACT-DATE-TIME (date-2 '%m/%d') to alphanum-1.
It's a stinker - I guess I will have to format as 2012/11/28 and 
then SUBSTRING out the slashes.
It seems that once the slashes or spaces are gone from the edit 
string, the compiler chokes because it thinks it is numeric.
Is it possible that it is impossible to pull the most common date 
format?  Does no one else use the cobol compiler with dates?
So here is the ugly code that I created:
move function EXTRACT-DATE-TIME (ws-date  '@Y/%m/%d') 
     to ws-date-yyyy-mm-dd 
string ws-date-yyyy-mm-dd (1:4) 
       ws-date-yyyy-mm-dd (6:2) 
       ws-date-yyyy-mm-dd (9:2) 
delimited by size into A0468X-DUE-DATE of AFTR 
Does anyone else use DATE functions in COBOL/ILE?  Maybe the are 
full of bugs??
As an Amazon Associate we earn from qualifying purchases.