Focal Point
[SOLVED] Convert Date to Alpha Month and Year only (ex. May 2009)

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

October 15, 2009, 05:29 PM
Kulot
[SOLVED] Convert Date to Alpha Month and Year only (ex. May 2009)
I have a report that has a footer that contains the previous month and year, but I need it to be in an alphanumeric month and year only.

I am able to get the previous month by doing the following:

-SET &Today_Date_YYMD = DATECVT(&YYMD,'I8YYMD','YYMD');
-SET &Begin_Month = DATEMOV(&Today_Date_YYMD,'BOM');
-SET &Last_End_Month = DATEADD(&Begin_Month, 'D', -1);
-SET &Last_End_Month_I8 = DATECVT(&Last_End_Month,'YYMD','I8YYMD');

But from this point on, I don't know how to make it look like September 2009.

My plan was to use it on the footer like this:
"Printed on <+0>&Last_Month_Year "

I have been searching Focal Point and couldn't find a similar situation.
I had been searching the "Almost 1001 Ways to Work With DATES in WebFOCUS" book but can't find the solution.

Thanks in advance for helping!

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


WF767, WinServ2003, SQLServ2000
HTML
October 15, 2009, 05:42 PM
N.Selph
You can do something like this to your resulting date:
 
-SET &DT_ALPHA = DATECVT(&CPERIOD, 'I8YYMD', 'A6MDY');
-SET &DISPLAY_DT = CHGDAT('A6MDY','MDYYX',&DT_ALPHA, 'A17');


Using your &Last_End_Month_I8 instead of &CPERIOD.


(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)
October 15, 2009, 05:44 PM
Waz
As this is going to be in a footing, I would suggest useing a DEFINE field

DEFINE FILE CAR
Today/YYMD = &YYMD;
Last/MtrYY   = DATEADD(Today, 'M',-1);
END
TABLE FILE CAR
PRINT COUNTRY Today Last
FOOTING
"Month: <Last"
END



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 15, 2009, 08:01 PM
Kulot
Thanks N.Selph and Waz!!!

Somehow the -SET option keeps on returning a 19th century year. Here are the displays:

-SET &Today_Date_YYMD = DATECVT(20090531,'I8YYMD','YYMD');
-SET &Begin_Month = DATEMOV(39598,'BOM');
-SET &Last_End_Month = DATEADD(39568, 'D', -1);
-SET &Last_End_Month_I8 = DATECVT(39567,'YYMD', 'I8YYMD');
-SET &DT_ALPHA = DATECVT(20090430, 'I8YYMD', 'A6MDY');
-SET &DISPLAY_DT = CHGDAT('A6MDY','MDYYX',043009, 'A17');
-TYPE Today_Date_YYMD - 39598;
-TYPE Begin_Month - 39568;
-TYPE Last_End_Month - 39567;
-TYPE Last_End_Month_I8 - 20090430;
-TYPE DT_ALPHA - 043009;
-TYPE DISPLAY_DT - APRIL 30 1909 ;

Im sure it will work with just a few more changes.
I was able to remove the date but I could not fix the century.
It must had something to do with our y2k threshold settings.

I did the one in the DEFINE section and it worked fine.

Thanks again!
I think I will meet tomorrow's deadline for this report because of this!


WF767, WinServ2003, SQLServ2000
HTML
October 15, 2009, 08:11 PM
Waz
If you have issues with 19th century, then use DEFCENT and YRTHRESH to set an active 100 year window.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 16, 2009, 09:56 AM
jgelona
Try this:

-SET &RUNDATE=AYM(&YYMD/100,-1,'I6YYM');
-SET &RUNDATE=CHGDAT('I6YYM','MYYX',&RUNDATE, 'A17');
-TYPE &RUNDATE



In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.