Focal Point
[SOLVED] Date conversion help

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

October 10, 2014, 06:35 AM
VS4
[SOLVED] Date conversion help
Hi ,
I need to convert an alphanumeric
'Sat 02/03/13' to a YYMD Date format.

I have tried
DEFINE NEW_FINISH/DMY=DATECVT(EDIT(GETTOK(FINISH,50,-1,' ',50,'A50'),'99$99$99'),'A6DMY','DMY');

with above I could able to convert it to DMY date format however from DMY to YYMD its transalting as 1913/03/02 , I need 2013/03/02.
how can I achieve this ? seems Y2K issue.
Regards
VS

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


WebFOCUS8,IWAY DM
Windows, All Outputs
October 11, 2014, 06:00 AM
Alan B
There are 2 parameters for setting the century, often referred to as the sliding window technique. These are DEFCENT and YRTHRESH. Any value below YRTHRESH has century set to DEFCENT+1.

I would use:
DEFINE ALPHA_FINISH/A6DMY= EDIT(GETTOK(INPUT,50,-1,' ',8,'A8'),'99$99$99');
DEFINE YYMD_FINISH/YYMD DEFCENT 19 YRTHRESH 52  = ALPHA_FINISH;

to get the correct century.


Alan.
WF 7.705/8.007
October 11, 2014, 12:14 PM
George Patton
Alan's version is probably cleaner. But there are several ways - here's another one. (You could just use the edit once to strip of the 'Sat ' and then CHGDAT to change the display order, for example.) I haven't used GETTOK in a long time and it's nice to be reminded that it exists.

(If you have dates going back to the previous century you'll have to make adjustments of course. The DEFCENT and YRTHRESH are one way of checking if a date belongs in that last century or this one - but of course you can do the same with IF ... ELSE statements).

quote:
'Sat 02/03/13'

DEFINE FILE CAR
OLDDATE/A12='Sat 02/03/13';
NEWDATE1/A8='20' | EDIT(OLDDATE, '$$$$$$$$$$99') | EDIT(OLDDATE, '$$$$$$$99$$$') | EDIT(OLDDATE, '$$$$99$$$$$$$$');
NEWDATE2/YYMD=DATECVT(NEWDATE1, 'A8YYMD', 'YYMD');
END

TABLE FILE CAR
PRINT NEWDATE1 
NEWDATE2 
BY CAR NOPRINT
BY OLDDATE
WHERE RECORDLIMIT EQ 1
END

This message has been edited. Last edited by: George Patton,


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
October 13, 2014, 03:54 AM
VS4
thanks , both methods are working ..

Regards
VS


WebFOCUS8,IWAY DM
Windows, All Outputs