Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Month calculation

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]Month calculation
 Login/Join
 
Platinum Member
posted
In this simple example, why does &prevmonth show as '1' instead of '01'?

-SET &CURYR = &DATEYY;
-SET &PREVYR = &DATEYY - 1;
-SET &CURMO = &DATEM ;
-SET &PREVMONTH = &CURMO - 1;
-SET &PREVMO = IF &CURMO  EQ 1 THEN 12 ELSE &PREVMONTH.EVAL;
-SET &CURRYM = '&DATEYY.EVAL' | '&DATEM.EVAL';
-SET &PREVYM = '&PREVYR.EVAL' | '&PREVMO.EVAL';
-SET &MODM = EDIT (MODIFY_DATE,'$$$$$99$$$');
-TYPE &CURYR &CURMO &PREVMO &CURRYM &PREVYM &CURMO &PREVMONTH
-RUN
-EXIT  

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


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
 
Posts: 116 | Registered: April 23, 2007Report This Post
Expert
posted Hide Post
Because you're working with integers, not dates.

-SET &ECHO=ALL;

-SET &CURYR = &DATEYY;
-SET &PREVYR = &DATEYY - 1;
-SET &CURMO = &DATEM ;
-SET &PREVMONTH = &CURMO - 1;
-SET &PREVMONTH = IF &PREVMONTH LT 10 THEN '0' | &PREVMONTH ELSE &PREVMONTH;
-SET &PREVMO = IF &CURMO  EQ 1 THEN 12 ELSE &PREVMONTH;
-SET &CURRYM = &DATEYY | &DATEM.;
-SET &PREVYM = &PREVYR | &PREVMO;
-SET &MODM = EDIT (MODIFY_DATE,'$$$$$99$$$');

-TYPE CURYR    : &CURYR
-TYPE CURMO    : &CURMO
-TYPE PREVMO   : &PREVMO
-TYPE CURRYM   : &CURRYM
-TYPE PREVYM   : &PREVYM
-TYPE CURMO    : &CURMO
-TYPE PREVMONTH: &PREVMONTH


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Tom beat me to the punch.

You don't need the EVAL suffix here.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Because you are treating it as a numeric value and not as ac actual DATE component.

02 - 1 => 1


If you need to go to the previous month and have it always represented as "MM" you should use DATE functions instead; if we were still in January, PREVMONTH should be "12" but your expression would return => 01 - 1 -> 0 which is wrong.

Try something like:
-SET &PREVMONTH = EDIT(DATECVT(DATEADD(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'M', -1), 'YYMD', 'A8YYMD'), '$$$$99$$');


Not necessarily short but surely safer!

- Neftali.



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.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Expert
posted Hide Post
Francis,

We both had essentially the same thing, so, I deleted mine! Smiler


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Virtuoso
posted Hide Post
Better yet, just determine what your previous month is and from there obtain all of the independent components you need:

quote:

-SET &PREVMONTH = DATECVT(DATEADD(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'M', -1), 'YYMD', 'A8YYMD');
-SET &PREVMO = EDIT(&PREVMONTH, '$$$$99$$');
-SET &PREVYM = EDIT(&PREVMONTH, '999999$$');
...



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.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Platinum Member
posted Hide Post
Got it, Thank You


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
 
Posts: 116 | Registered: April 23, 2007Report This Post
Virtuoso
posted Hide Post
You can also use the legacy function AYM to add/subtract months.

-SET &PREVYY  = &DATEYY - 1 ;
-SET &CURYYM  = &DATEYY | &DATEM ;
-SET &PREVYYM = AYM(&CURYYM,-1,'I6');
-*
-TYPE DATEYY  = &DATEYY
-TYPE PREVYY  = &PREVYY
-TYPE CURYYM  = &CURYYM
-TYPE PREVYYM = &PREVYYM


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]Month calculation

Copyright © 1996-2020 Information Builders