Focal Point
[SOLVED] Date Conversion

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

June 15, 2007, 02:06 PM
Mike Johnson
[SOLVED] Date Conversion
I need to convert a alpha to a smart date.

The alpha format is: 070523, YMD.

I need it to be a smart date in this format YYMD.

I've tried the following with no success.

NLETY/A2 = EDIT ('&LETTING', '$$99');
NLETM/A2 = EDIT ('&LETTING', '$$$$99');
NLETD/A2 = EDIT ('&LETTING', '$$$$$$99');
NLETDATE/A16 = '20'||NLETY||'-'||NLETM||'-'||NLETD||' 00:00';
LETTING/YYMD = HDATE(NLETDATE, 'YYMD');


&LETTING = CT070523
Thanks

This message has been edited. Last edited by: Kerry,
June 15, 2007, 02:11 PM
N.Selph
Try-

 
LETTING=DATECVT('&LETTING','A6MDY','YYMD');
 



(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
June 15, 2007, 02:27 PM
Mike Johnson
Nope, returned .00
June 15, 2007, 02:46 PM
Leo L
I tried this with success...

-SET &DAYIN = '070523';
-SET &DAYIN = '20' || &DAYIN;

DEFINE FILE CAR
DATEIN/YYMD = &DAYIN;
END

TABLE FILE CAR
PRINT DATEIN
BY MODEL
IF RECORDLIMIT EQ 5
END


or with the year threshold to get it in the year 2000

SET DEFCENT=19
SET YRTHRESH=56 
-SET &DAYIN = '070523';
DEFINE FILE CAR
DATEIN/YYMD = &DAYIN;
END

TABLE FILE CAR
PRINT DATEIN
BY MODEL
IF RECORDLIMIT EQ 5
END

*thanks Alan B for that one.. I knew it was simple... just never needed it.

This message has been edited. Last edited by: Leo L,


Prod: WebFOCUS 7.6.4 - Self Service - Windows Server2003 - Apache Tomcat 5.5
Dev: WebFOCUS 7.6.4 - Self Service - Windows XP SP2 - Apache Tomcat 5.5
June 15, 2007, 02:48 PM
Alan B
Nick forgot to put a format on, that's all.

LETTING/YYMD=DATECVT('&LETTING','A6YMD','YYMD');

You may want to SET DEFCENT=19 and SET YRTHRESH=56 as well.


Alan.
WF 7.705/8.007
June 15, 2007, 03:08 PM
Leah
quote:
The alpha format is: 070523, YMD.


Using defines, this works too;
-SET &LETTING= 070515;
SET DEFCENT=19
SET YRTHRESH=56

DEFINE FILE EMPLOYEE
IDATE1/I6YMD = EDIT('&LETTING');
MYDATE/YYMD=IDATE1;
END
TABLE FILE EMPLOYEE
SUM CURR_SAL FST.IDATE1 FST.MYDATE
END


Leah
June 15, 2007, 03:25 PM
Mike Johnson
Not sure what I'm doing wrong but none of the suggestions are working.

SET DEFCENT=19
SET YRTHRESH=56
DEFINE FILE EMPLOYEE
NDATE/A6 = EDIT ('$LETTING', '$$999999');
NLETDATE/I6 = EDIT(NDATE);
LETTING/YYMD = NLETDATE;
-*LETTING/YYMD=DATECVT('&LETTING','A6MDY','YYMD');
END

Don't forget that &LETTING = 'CT070523' NOT '070523'
June 15, 2007, 03:29 PM
Mike Johnson
quote:
SET DEFCENT=19
SET YRTHRESH=56
-SET &DAYIN = '070523';
DEFINE FILE CAR
DATEIN/YYMD = &DAYIN;


Sorry, I overlooked one sugguestion. the following one worked Thanks alot for the quick response.

SET DEFCENT=19
SET YRTHRESH=56
-SET &DAYIN = '070523';
DEFINE FILE CAR
DATEIN/YYMD = &DAYIN;
February 05, 2010, 03:53 PM
nsk110483
Hi All,

My date format is 2009/10/23
how to convert the same to 200910


In Focus since 2008
WebFOCUS 8.2.0.1
Windows 7 - IE,Chrome,Firefox
Excel, PDF, HTML, AHTML, XML
JavaScript, jQuery, D3.js, Highcharts
February 05, 2010, 04:28 PM
Dan Satchell
If your date is in an ampersand variable, you can use the EDIT function:

-SET &NEWDATE = EDIT(&OLDDATE,'9999$99$$$');



WebFOCUS 7.7.05
February 05, 2010, 05:29 PM
njsden
If it isn't an ampersand variable but an actual date field instead, then you will need to convert it from DATE to ALPHA and then extract the pieces you need.

Please review the documentation for DATECVT and other DATE functions which you will surely need in the future.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.