Focal Point
[CLOSED] Converting YYMD (data) to YYYYMMDD (integer)

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/6807011986

January 25, 2018, 02:01 PM
Max Nevill
[CLOSED] Converting YYMD (data) to YYYYMMDD (integer)
Any thoughts on how to do this? I want to take 2016-01-12 (YYMD) to turn into 20160112 (integer).

I tried taking

DPART(DATE,YEAR) | DPART(DATE,MONTH) | DPART(DATE,DAY)

But that threw an error, expecting alpha fields.

Then I tried

EDIT(DPART(DATE,YEAR)) | EDIT(DPART(DATE,MONTH)) | EDIT(DPART(DATE,DAY))

And that just gave me jibberish. Any thoughts?

This message has been edited. Last edited by: FP Mod Chuck,


WebFocus 8.104
Windows 7 Entreprise, SP1
January 25, 2018, 02:32 PM
Tom Flynn
Hi Max,
Did you try NEW_DATE/I8 = YOUR_YYMD_DATE_FIELD;
If that doesn't work, try the FPRINT function...
Tom


Tom Flynn
WebFOCUS 7.7.05 - PROD/QA
DB2 - AS400 - Mainframe
January 25, 2018, 03:47 PM
j.gross
quote:
NEW_DATE/I8 = YOUR_YYMD_DATE_FIELD;

Better,
NEW_DATE/I8YYMD = YOUR_YYMD_DATE_FIELD;

January 25, 2018, 04:32 PM
Max Nevill
Good suggestion Tom.

Trying NEWDATE/I8 = DATEFIELD gave me a 5 digit number conversion, which wasn't I needed unfortunately.

FPRINT(DATEFILED, 'YYMD','I8')

gave the error:

1 FILE(S) LOADED
0 ERROR AT OR NEAR LINE 10 IN PROCEDURE TEST_TRN58FOCEXEC *
(FOC36355) INVALID TYPE OF ARGUMENT #3 FOR USER FUNCTION FPRINT
(FOC101) ERROR IN DEFINE IN MASTER FILE: TABLE_NAME
BYPASSING TO END OF COMMAND

So then I just got fancy and over-engineered the function.

EDIT(SUBSTV(10, FPRINT(START_DATE, 'YYMD', 'A10'),1,4,'A4') | SUBSTV(10, FPRINT(START_DATE, 'YYMD', 'A10'),6,7,'A2') | SUBSTV(10, FPRINT(START_DATE, 'YYMD', 'A10'),9,10,'A2'))

Maybe more work than necessary, but gets the job done. Thanks for the help!


WebFocus 8.104
Windows 7 Entreprise, SP1
January 25, 2018, 04:33 PM
Max Nevill
quote:
Originally posted by j.gross:
quote:
NEW_DATE/I8 = YOUR_YYMD_DATE_FIELD;

Better,
NEW_DATE/I8YYMD = YOUR_YYMD_DATE_FIELD;


That keeps the "/" which I want to get rid of.


WebFocus 8.104
Windows 7 Entreprise, SP1
January 28, 2018, 03:25 PM
Waz
quote:
That keeps the "/" which I want to get rid of.


That is a formatted integer.

Just assign result to an I8 field


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

January 29, 2018, 09:47 AM
dbeagan
Need to use I8YYMD

 TABLE FILE systable
 PRINT NAME NOPRINT
 COMPUTE SOMEDAY/YYMD    = 20131211;
 COMPUTE SOMEDAY2/I8YYMD = SOMEDAY;
 COMPUTE SOMEDAY_I8/I8   = SOMEDAY2;
 WHERE RECORDLIMIT IS 1
 END  



WF 8.2.03
Win10 / IE11
AHTML EXL2K PDF COMT WP ZIP
January 30, 2018, 10:54 AM
Hallway
Try using the DATECVT function:
https://webfocusinfocenter.inf...r/source/datecvt.htm

 INT_DATE/I8 = DATECVT ( YYMD_DATE, 'YYMD', 'I8YYMD'); 



Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All