Focal Point
[SOLVED] Hot to convert a packed date field to display in MDYY format

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4907067336

September 26, 2013, 02:39 PM
Rhonda
[SOLVED] Hot to convert a packed date field to display in MDYY format
Here is the problem, I am working with SMF records which are VSAM records. They come with FOCUS. The field in the SMFFIX MASTER
has these attibutes FIELD=SMFOFDTE,,P9 ,P4 ,$ DATE, PACKED (0CYYDDDF)

The following DEFINEs:
PDATE/P9=SMFOFDTE;
IDATE/I9=PDATE;
ODATE/I8YYMD=DTYMD(IDATE, ODATE);
SMFDATE/MDYY=ODATE;

Results:
SMFOFMSO USER SMFOFDTE PDATE IDATE ODATE SMFDATE
EDA77TW1 actrrc1 113245 113245 113245 2210/01/20 01/20/2210
113245 113245 113245 2210/01/20 01/20/2210
113247 113247 113247 2210/01/22 01/22/2210
113247 113247 113247 2210/01/22 01/22/2210

I have not worked with packed date fields in a very long time. What am I missing?

Thanks in advance - Rhonda

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML
September 26, 2013, 02:50 PM
Tom Flynn
Hi Rhonda,
If I recall, packed date columns correleate to:
 
Byte 1:    Converts to a century 0=19, 1=20
Bytes 2-3: YY
Bytes 4-6: Day of the Year(Julian)


May need to use JULDAT/GREGDT functions...
hth
Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
September 26, 2013, 02:53 PM
Francis Mariani
Your code looks OK, though you could probably skip a couple of steps, but is the clue in the comment at the end of the metadata line, "0CYYDDDF"? Is it possible that the field does not contain a conventional date?

I don't know what the "F" stands for, but looking at "113245" - does the 11 mean 2011, is the 324 a component of a Julian date?

SMFOFMSO USER    SMFOFDTE PDATE  IDATE  ODATE      SMFDATE
-------- ------- -------- ------ ------ ---------- ----------
EDA77TW1 actrrc1 113245   113245 113245 2210/01/20 01/20/2210
                 113245   113245 113245 2210/01/20 01/20/2210
                 113247   113247 113247 2210/01/22 01/22/2210
                 113247   113247 113247 2210/01/22 01/22/2210 



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
September 27, 2013, 05:36 AM
GamP
Tom is almost right. From the IBM info center:
Definition of the format used to represent dates (OCYYDDD+)
The numbers are written in +ve byte packed decimal.
'0C' is the number of centuries since 1900. All dates in the 21st century have '01'.
'YY' is the year.
'DDD' is the day of the year. The first day of the year is '1' and the last day of the year '366'.
'+' is hard coded as 0xC.
So:
10 January 2007  = 0107010C
 1 January 2001  = 0101001C
31 December 2012 = 0112366C



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
September 27, 2013, 11:58 AM
Rhonda
Thank you for all for your help! Here are the defines I created I may have taken more steps than necessary to get what I wanted but it was worth it. Thanks again!
*************************
PDATE/P6=SMFOFDTE;
IDATE/I6=PDATE;
ZDATE/A5=EDIT(IDATE,'$99999');
XDATE/I5=EDIT(ZDATE);
GREG_DATE/I8 = GREGDT(XDATE,'I8');
********************************
Rhonda


WebFOCUS & ReportCaster 8.1.05, 7.7.03 - AIX/LINUX, FOCUS 7.6.13 MVS, Output PDF, XLS-XLSX, DOCX and HTML