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 , February 06, 2018 05:50 PM 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
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!
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.
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
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 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');