[focus-l] Re: Date mess. . .

  • From: "John W Price" <pricejw@xxxxxxxxxxx>
  • To: <focus-l@xxxxxxxxxxxxx>
  • Date: Tue, 7 Jun 2005 08:11:21 -0700

Here is the code to convert the examples you listed:

FILEDEF TEST DISK TEST.DAT
DEFINE FILE TEST
-* pull the mont out
ALPH_MON/A2=IF EDIT(DATEMDY,'$9') EQ '/'
            THEN EDIT(DATEMDY,'09')
            ELSE EDIT(DATEMDY,'99') ;
-* pull the day out
ALPH_DAY/A2=IF EDIT(DATEMDY,'$$$9') EQ '/'
            THEN EDIT(DATEMDY,'$$09')
            ELSE IF EDIT(DATEMDY,'$$$$9') EQ '/'
            THEN EDIT(DATEMDY,'$$$09')
            ELSE EDIT(DATEMDY,'$$$99') ;
-* pull the year out
ALPH_YEAR/A4=IF EDIT(DATEMDY,'$$$9') EQ '/'
             THEN EDIT(DATEMDY,'$$$$9999')
             ELSE IF EDIT(DATEMDY,'$$$$9') EQ '/'
             THEN EDIT(DATEMDY,'$$$$$9999')
             ELSE EDIT(DATEMDY,'$$$$$$9999') ;
-* convert to integer to add leading zeroes when not in the number
INT_YEAR/I4 = EDIT(ALPH_YEAR) ;
INT_MON/I2 =  EDIT(ALPH_MON) ;
INT_DAY/I2 =  EDIT(ALPH_DAY) ;
-* convert to an alphanumeric legacy date
ALPH_DATE/A8YYMD = EDIT(INT_YEAR) |EDIT(INT_MON) |EDIT(INT_DAY) ;
-* convert to a smart-date
SD_DATE/YYMD = ALPH_DATE ;
END

Results:
 DATEMDY     ALPH_DATE   SD_DATE   
 -------     ---------   -------   
 8/3/2004    2004/08/03  2004/08/03
 8/ 3/2004   2004/08/03  2004/08/03
  8/03/2004  2004/08/03  2004/08/03

Above is derived from "(Almost) 1001 ways to Work with Date in WebFOCUS"
which is available from www.aviter.com

Hope this helps. 
John Price

-----Original Message-----
From: focus-l-bounce@xxxxxxxxxxxxx [mailto:focus-l-bounce@xxxxxxxxxxxxx] On
Behalf Of Hamilton, Robert L
Sent: Tuesday, June 07, 2005 7:22 AM
To: focus-l@xxxxxxxxxxxxx
Subject: [focus-l] Date mess. . .

We get dates from the government with a mish-mash of date formats and this
one has me stumped
 
?m/xd/ccyy
 
where ? can be blank or null or 0 or 1  AND x can be blank, null, zero,1,2,
or 3.
 
examples
 
8/3/2004
8/ 3/2004
 8/03/2004
 
et al.
 
I need it sortable as in  ccyymmdd.  The string has many other fields; it's
csv in the PC world so I could go thru with objrexx and unstring the thing
before up loading to z/OS  but a FOCUS solution would be helpful. . .
 
thnx
 
bobh




Other related posts: