Focal Point
[CLOSED] Date Conversion

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

May 24, 2011, 12:50 PM
Deepu
[CLOSED] Date Conversion
Hi All,

I have a Data like this

FIELD_DATE
01/28/2010
05/22/2010
02/16/2011
03/18/2011

I would like to convert in this format

i have to display only Month and year only

FIELD_DATE
Jan 10
May 10
Feb 11
Mar 11


can any one tell me how to do i'm new to webfocus plz

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


WebFOCUS 7.6
Windows, All Outputs
May 24, 2011, 01:17 PM
FrankDutch
Deepu
Did you do a search on this issue?

This is in fact rather basic, but it depends on the internal format of you field_date

Suppose it is a smartdate in your database

then

DEFINE FILE XXX
FIELD_NEW/tMYY=FIELD_DATE;
END
TABLE FILE XXX
PRINT 
FIELD_DATE FIELD_NEW
END


but please ...Read your manuals, use the application help function, do a search on this form.
And finaly....buy the excelent book I have pointed to many many times.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

May 25, 2011, 09:14 AM
Deepu
quote:


That field in format alpha FIELD_DATE(A10) i need to convert in integer

I have a Data like this


FIELD_DATE
01/28/2010
05/22/2010
02/16/2011
03/18/2011

I would like to convert in this format

i have to display only Month and year only

FIELD_DATE
Jan 10
May 10
Feb 11
Mar 11



WebFOCUS 7.6
Windows, All Outputs
May 25, 2011, 10:04 AM
Francis Mariani
It appears to be more complicated than I thought!

This doesn't work on a Date field: TEMP_DATE/MtD. Other Date formats work, but just Month and Day do not (see code below).

Without converting the Date to a Date/Time field, it appears you must use a combination of EDIT, CHGDAT and LCWORD.

Hopefully there's a better way.

DEFINE FILE CAR
ORIGINAL_DATE/A10 WITH COUNTRY = '11/28/2010';
END

TABLE FILE CAR
PRINT

COMPUTE FINAL_DATE1/A6 = CHGDAT('MDYY', 'MTD', EDIT(ORIGINAL_DATE,'99$99$9999'), 'A6');

COMPUTE FINAL_DATE2/A6 = LCWORD(6, FINAL_DATE1, 'A6');

ORIGINAL_DATE

COMPUTE DATE1/A8MDYY = EDIT(ORIGINAL_DATE,'99$99$9999');

COMPUTE TEMP_DATE/YYMD = DATE1;

TEMP_DATE/YMD
TEMP_DATE/YYM
TEMP_DATE/YM
TEMP_DATE/MtDYY
TEMP_DATE/MtDY
TEMP_DATE/MtYY
TEMP_DATE/MtY
TEMP_DATE/Mt
TEMP_DATE/M
-*TEMP_DATE/MtD
TEMP_DATE/YYQ
TEMP_DATE/YQ
TEMP_DATE/Q

WHERE RECORDLIMIT EQ 1
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 25, 2011, 12:14 PM
Dan Satchell
WebFOCUS can format a SmartDate as 'Mmm, YY' or as 'MM YY', but for some reason it cannot chew Bits and rub it's logo at the same time - no combination of MY and Bt seems to work:

DEFINE FILE CAR
 ORIGINAL_DATE/A10 WITH COUNTRY = '11/28/2010';
 ALPHA_DATE/A8MDYY = EDIT(ORIGINAL_DATE,'99$99$9999');
 SMART_DATE1/MBY = ALPHA_DATE ;
 SMART_DATE2/MtY = ALPHA_DATE ;
END

TABLE FILE CAR
 PRINT
  ORIGINAL_DATE
  ALPHA_DATE
  SMART_DATE1
  SMART_DATE2
 WHERE RECORDLIMIT EQ 1 ;
END



WebFOCUS 7.7.05
May 25, 2011, 12:32 PM
Francis Mariani
Correction on my previous post - for some reason I though the requirement was for Month/Day (MtD), while it's really for Month/Year (MtY).

So, MtY is no problem, but MtD is not possible and I cannot figure out why - I'd love to open a case.


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