Focal Point
[SOLVED]Compute Last Month's date in Dialogue Manager

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

November 15, 2011, 11:34 AM
SeyedG
[SOLVED]Compute Last Month's date in Dialogue Manager
Hi all,
I have searched this site for solutions in getting last month date in Dialogue Manager in month-yyyy (i.e. October-2011) format. I tried many of these solutions, but haven't been able to get them to work. Your input is greatly appreciated.


Seyed

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


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)
November 15, 2011, 12:17 PM
Crymsyn
Does this work for you?

-SET &LASTMONTH=AYM(EDIT(EDIT(&YYMD,'999999$$')),-1,'I6YYM');
-SET &LASTMONTH_DESC=CHGDAT('I8YYMD','MYYX',&LASTMONTH,'A17');



WF: 8201, OS: Windows, Output: HTML, PDF, Excel
November 15, 2011, 12:33 PM
SeyedG
I just tried your solution, the result is blank.

Thank you,

Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)
November 15, 2011, 12:50 PM
njsden
Works for me! You evaluated the resulting value of &LASTMONTH_DESC and it was blank?

In my environment, &LASTMONTH_DESC was assigned a value of "OCTOBER 2011".



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.
November 15, 2011, 12:50 PM
Francis Mariani
The result is blank? Is this because the code worked as expected?

Add
-TYPE &LASTMONTH_DESC
-TYPE &LASTMONTH
to see that it works.


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
November 15, 2011, 01:58 PM
SeyedG
quote:
-TYPE &LASTMONTH_DESC
-TYPE &LASTMONTH

The following code results
-SET &LASTMONTH=AYM(EDIT(EDIT(&YYMD,'999999$$')),-1,'I6YYM');
-SET &LASTMONTH_DESC=CHGDAT('I8YYMD','MYYX',&LASTMONTH,'A17');

-TYPE &LASTMONTH_DESC
-TYPE &LASTMONTH


in

0


It looked like the '&YYMD' does not have a value to process, but when I type &YYMD, I get '20111115' which is correct.

Thanks,


Seyed
November 15, 2011, 02:10 PM
Dan Satchell
Try this:

-SET &THIS_MONTH     = EDIT(&YYMD,'999999$$');
-SET &LAST_MONTH     = AYM(&THIS_MONTH,-1,'I6YYM');
-SET &LASTMONTH_DESC = CHGDAT('I8YYMD','MYYX',&LAST_MONTH,'A17');

-TYPE &LAST_MONTH
-TYPE &LASTMONTH_DESC



WebFOCUS 7.7.05
November 15, 2011, 02:25 PM
SeyedG
Hi all,
Thank you very much for your inputs. Dan’s solution worked for me. There is one more tweak that I must do. I now how to figure out a way to convert the result from ‘OCTOBER 2011’ to ‘October-2011’ with a dash in between and month name being as Microsoft Word calls it “title case”d.

Thanks again to Dan and everyone who contributed.

Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)
November 15, 2011, 02:32 PM
Microfich
This gets it all:

 
-SET &DATE1 = CHGDAT('YYMD', 'MXYY', DATECVT(DATEADD(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'M', -1),'YYMD','A8YYMD'), 'A17');
-SET &DATE2 = EDIT(&DATE1,'9')|LOCASE(17,EDIT(&DATE1,'$9999999999999999'),'A17');
-SET &DATE3 = STRREP(&DATE2.LENGTH,&DATE2,2,' 2''',2,'-2''',&DATE2.LENGTH,'A&DATE2.LENGTH');

-TYPE &DATE1 &DATE2 &DATE3

 



WebFOCUS 8105
Windows;
DB2, UDB, SQL Server, Oracle
FOCUS-WebFOCUS since 1981
November 15, 2011, 02:37 PM
SeyedG
Hi Microfich,
Thank you very much. Your solution worked nicely. Again, thanks everyone.

Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)
November 15, 2011, 03:00 PM
njsden
Here's yet another way:

-SET &LASTMONTH      = DATECVT(DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'M',-1),'YYMD','A8YYMD'),'A8YYMD','MYY');
-SET &LASTMONTH_DESC = DATETRAN(&LASTMONTH, '(MYY)', '(tr-)', 'EN', 20, 'A20');
-TYPE &LASTMONTH_DESC




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.
November 15, 2011, 04:59 PM
SeyedG
quote:
-SET &LASTMONTH = DATECVT(DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'),'M',-1),'YYMD','A8YYMD'),'A8YYMD','MYY');
-SET &LASTMONTH_DESC = DATETRAN(&LASTMONTH, '(MYY)', '(tr-)', 'EN', 20, 'A20');
-TYPE &LASTMONTH_DESC


Hi njsden,
I appreciate your input.

Seyed


WebFOCUS 8.0.09
App Studio 8009
Linux Kernel-2.6
DBMS: Oracle 11g
all output (Excel, HTML, AHTML, PDF)