Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Convert alpha date in mainframe FOCUS to date format

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Convert alpha date in mainframe FOCUS to date format
 Login/Join
 
Guru
posted
I have a datafile that contians dates in alphaformat, ,arranged as so: 20082 (Contains only the current year and a number representing a particular quarter of the year). How might I convert that date to a numeric calendar format?

I'm running mainframe FOCUS Release 7.1, which is awfully arcaic, but I work for an educational organization and can only work with what tools I am given.

Thanks in advance!

This message has been edited. Last edited by: Kerry,


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
 
Posts: 250 | Registered: January 14, 2008Report This Post
Master
posted Hide Post
This is a very easy task for Maintain. Your code could look like this:

MAINTAIN
COMPUTE X/A10 = '20082';
COMPUTE Y/A4 = SUBSTR(X, 1, 4);
COMPUTE Z/A1 = SUBSTR(X, 5, 1);
COMPUTE Z1/A4;
IF Z = 1 THEN COMPUTE Z1 = '0101';
IF Z = 2 THEN COMPUTE Z1 = '0401';
IF Z = 3 THEN COMPUTE Z1 = '0701';
IF Z = 4 THEN COMPUTE Z1 = '1001';
COMPUTE X2/MDYY= Z1 || Y;
TYPE "X2 = <END

Here I am just computing X to a value, but you could load the data into a stack and do a loop. I get the year and the quarter, and just compute them to a standard MDYY assuming standard starting dates of quarters.

If you need help loading the data or creating the loop, post the Master. Of course, the format of X2 can be an alpha or any other date format.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Expert
posted Hide Post
DEFINE FILE CAR
DT_YQ/A5 WITH COUNTRY =
IF COUNTRY EQ 'ENGLAND' THEN '20091' ELSE
IF COUNTRY EQ 'FRANCE'  THEN '20042' ELSE
IF COUNTRY EQ 'ITALY'   THEN '20083' ELSE '20044';

DATE1/A8 =
IF EDIT(DT_YQ,'$$$$9') EQ '1' THEN EDIT(DT_YQ,'9999$') || '0101' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '2' THEN EDIT(DT_YQ,'9999$') || '0401' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '3' THEN EDIT(DT_YQ,'9999$') || '0701' ELSE
IF EDIT(DT_YQ,'$$$$9') EQ '4' THEN EDIT(DT_YQ,'9999$') || '1001' ELSE '0';
DATE2/I8 = EDIT(DATE1);
END

TABLE FILE CAR
PRINT DATE2
END

You can further convert DATE2 to a Date format or a Date-Time format field.

(


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
Maintain and Francis,

Thank you for your fast replies! I think I suffered from brain loss earlier, and I appreciate your helping out. I'm incorporating your suggestions and think I will get this fixed very soon.

Thanks again!


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
 
Posts: 250 | Registered: January 14, 2008Report This Post
Gold member
posted Hide Post
Try:

  
DEFINE FILE XXX                             
MYI/I5 WITH DVAL = EDIT(MYAINPUT) ;         
MYQ/I2 = (MYI - (INT(MYI/10)*10)) ;         
MYOLD/I6YYM = (MYI - MYQ)*10 + ((MYQ*3)-2) ;
MYD/YYMD = MYOLD ;                          
END                                         
TABLE FILE XXX                              
PRINT MYAINPUT MYQ MYOLD MYD                
IF RECORDLIMIT EQ 10                        
END                                         


where MYAINPUT is your A5 input and MYD is a normal FOCUS newdate, which can be directly converted into any olddate format (e.g. A8YYMD etc.)


IBI Development
 
Posts: 61 | Registered: November 15, 2005Report This Post
Virtuoso
posted Hide Post
If you could define the incoming string as a legacy date field with YY and Q components, you could transform the legacy date to a 'smart' date by direct assignment. But the Q option was never incorporated in the legacy formats, so you have to make do with year+month formats.

Isolate the year and quarter, compute a month in the quarter, construct a legacy year+month date, and assign that to a year+quarter date:
EX -LINES 5 EDAPUT MASTER,DATES,CV,FILE
FILENAME=DATES, SUFFIX=FIX,$
SEGNAME=DATES, $
FIELD=DATE1 ,ALIAS=,A5 ,A5 ,$
FIELD=IGNORE ,ALIAS=,A75 ,A75 ,$

EX -LINES 5 EDAPUT FOCTEMP,DATES,CV,FILE
20001
20012
20023
20034

FILEDEF DATES DISK DATES.FTM
DEFINE FILE DATES
 AQ   /A1=EDIT(DATE1,'$$$$9');
 AM   /A2=DECODE AQ( 1 '03', 2 '06', 3 '09', ELSE '12');
 AYYM /A6YYM=EDIT(DATE1,'9999') | AM;
 YYQ  /YY-Q=AYYM;

END
TABLEF FILE DATES
LIST DATE1 AQ AM AYYM YYQ
END


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Can you just change the Usage of the master ?
EX -LINES 5 EDAPUT MASTER,DATES,CV,FILE
FILENAME=DATES, SUFFIX=FIX,$
SEGNAME=DATES, $
FIELD=DATE1 ,ALIAS=,YYQ ,A5 ,$
FIELD=IGNORE ,ALIAS=,A75 ,A75 ,$

EX -LINES 5 EDAPUT FOCTEMP,DATES,CV,FILE
20001
20012
20023
20034

FILEDEF DATES DISK dates.ftm

TABLE FILE DATES
PRINT DATE1
END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Convert alpha date in mainframe FOCUS to date format

Copyright © 1996-2020 Information Builders