Focal Point
[Closed]Converting an int to a date or alpha

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

May 04, 2016, 10:51 AM
Sherly
[Closed]Converting an int to a date or alpha
Hi
I tried to convert an integer field(I11) (201501) to an alpha or a date. I need to get the format of January 2015. I tried different functions and nothing seems to work. Can anyone help me. Below is the functions I used to get the date.

COMPUTE PCPYear3 /A4 = EDIT(PGIP_PHYSCIANSLIST,'9999');
COMPUTE PGIP_MONTH/I2 = DTPART(PGIP_PHYSCIANSLIST, MONTH);
COMPUTE PGIP_YEAR/I4 = DTPART(PGIP_PHYSCIANSLIST, YEAR);
COMPUTE PGIPYear1/YYM =PGIP_PHYSCIANSLIST;
COMPUTE PGIPYear = SUBSTR(6,PGIP_PHYSCIANSLIST,1,4,4,'A4');

Thanks,
Sherly
The version I am using is 8.1.05
Windows 7 Enterprise

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


WebFocus 8.x
Hyperstage
May 04, 2016, 10:56 AM
Francis Mariani
DEFINE FILE CAR
MY_INT_FIELD/I11 WITH COUNTRY = 201501;

MY_YYMI/I6YYM = MY_INT_FIELD;
MY_YYM/YYM = MY_YYMI;
END

TABLE FILE CAR
SUM
SALES
MY_INT_FIELD
MY_YYMI
MY_YYM
BY COUNTRY
END



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
May 04, 2016, 11:12 AM
Sherly
Hi Francis,
Do I need to hardcode the value of the date?
I tried the code below and the code failed

CStart_DT/I11 WITH PGIP_PHYSCIANSLIST = 201507;
My value should come from the table.

Sherly


WebFocus 8.x
Hyperstage
May 04, 2016, 11:18 AM
Vivian
Hi Sherly,

You might find answers to all those pesky date questions in Almost 1001 Ways to Work with Dates in WebFOCUS -- a handy book filled with examples! Available at www.aviter.com.


Vivian Perlmutter
Aviter, Inc.


WebFOCUS Keysheet Rel. 8.0.2
(Almost) 1001 Ways to Work with Dates thru Rel. 8.0.2
Focus since 1982
WebFOCUS since the beginning
Vivian@aviter.com

May 04, 2016, 11:48 AM
Tom Flynn
Hi Sherly,
Welcome to the WebFOCUS Forum.

Try this:

COMPUTE DATE0/I6YYM = PGIP_PHYSCIANSLIST;
COMPUTE DATE1/A6YYM = EDIT(DATE0);
COMPUTE MONTH_YR/A17 = LCWORD(17, CHGDAT('YYMD','MXYY',DATE1,'A17') ,'A17');


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 04, 2016, 12:05 PM
Sherly
it is working. Thank you so much for your help
Sherly


WebFocus 8.x
Hyperstage
May 04, 2016, 04:47 PM
Waz
Hi Sherly,

Can you update the title of your first port in this thread to add [CLOSED] or [SOLVED] if you are happy with the answer.


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!

May 05, 2016, 09:40 AM
Francis Mariani
"Do I need to hardcode the value of the date"

Sherly, since the CAR file doesn't have a date column, I had to concoct one. Of course the data can come from an existing column.


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