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] Previous 3 month name from a given Date

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Previous 3 month name from a given Date
 Login/Join
 
Gold member
posted
I want to get the previous three month name from a given date.Date format is YYMD.

Month name should be like Jan,Feb.

I am using WebFOCUS 7.6.1 version.I do not find any function for calculating month name from a date.

Please help.

Thanks in advance!

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 7.6.1
Windows, All Outputs
 
Posts: 50 | Location: Scun-thorpe,UK | Registered: November 14, 2012Report This Post
Expert
posted Hide Post
DEFINE FILE CAR
MY_DATE/YYMD = '&YYMD';
END
TABLE FILE CAR
PRINT
MY_DATE
COMPUTE MY_DATE_3M/YYMD = DATEADD(MY_DATE, 'M', -3);
MY_DATE_3M/Mt
BY COUNTRY
WHERE RECORDLIMIT EQ 1
END

This message has been edited. Last edited by: Francis Mariani,


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
Gold member
posted Hide Post
Thanks Francis Mariani.

But i do not want TABLE FILE for this requirement.

I want to store previous 3 month name in webfocus variables and use that variables in my report.


WebFOCUS 7.6.1
Windows, All Outputs
 
Posts: 50 | Location: Scun-thorpe,UK | Registered: November 14, 2012Report This Post
Guru
posted Hide Post
Convert to Smart Date to feed into DATEADD.
Convert to Alphanumeric to feed into CHGDAT.
Look over Date and Time Functions in the Help file to get a better understanding of what was done.
  
-SET  &LAST_3MONTH = CHGDAT('YYMD','MX', DATECVT(DATEADD(DATECVT(&YYMD, 'I8YYMD', 'YYMD'), 'M', -3), 'YYMD', 'A8YYMD'), 'A17');
-TYPE &LAST_3MONTH
-EXIT


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
 
Posts: 320 | Location: Memphis, TN | Registered: February 12, 2008Report This Post
Virtuoso
posted Hide Post
Or you could use the legacy function AYM to subtract 3 months from the current month:

-SET &CURR_MTH = EDIT(&DATEYYM,'9999$99');
-SET &MTH3_AGO = AYM(&CURR_MTH,-3,'I6YYM');
-SET &MTH_NAME = LCWORD(3,CHGDAT('A6YYM','MT',&MTH3_AGO,'A3'),'A3');
-TYPE &DATEYYM &MTH3_AGO &MTH_NAME


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Gold member
posted Hide Post
Thank you very much Mighty Max and Dan Satchell for such a small code.

I was done this using below code

  
-SET &DT1  = DATECVT(DATEADD(DATECVT (&YYMD,   'I8YYMD', 'YYMD'),'M', -1 ), 'YYMD','I8YYMD');
-SET &M1 = EDIT(&DT1,'$$$$99$$') ;
-SET &DT2  = DATECVT(DATEADD(DATECVT (&YYMD,   'I8YYMD', 'YYMD'),'M', -2 ), 'YYMD','I8YYMD');
-SET &M2 = EDIT(&DT2,'$$$$99$$') ;
-SET &DT3  = DATECVT(DATEADD(DATECVT (&YYMD,   'I8YYMD', 'YYMD'),'M', -3 ), 'YYMD','I8YYMD');
-SET &M3 = EDIT(&DT3,'$$$$99$$') ;
-TYPE &M1 &M2 &M3;
-SET &MM1 =  IF &M1 EQ 01 THEN 'Jan' ELSE IF &M1 EQ 02 THEN 'Feb' ELSE IF &M1 EQ 03 THEN 'Mar' ELSE IF &M1 EQ 04 THEN 'Apr' ELSE IF &M1 EQ 05 THEN 'May' ELSE IF &M1 EQ 06 THEN 'Jun' ELSE IF &M1 EQ 07 THEN 'Jul' ELSE IF &M1 EQ 08 THEN 'Aug' ELSE IF &M1 EQ 09 THEN 'Sep' ELSE IF &M1 EQ 10 THEN 'Oct' ELSE IF &M1 EQ 11 THEN 'Nov' ELSE 'Dec';
-TYPE &MM1;
-SET &MM2 =  IF &M2 EQ 01 THEN 'Jan' ELSE IF &M2 EQ 02 THEN 'Feb' ELSE IF &M2 EQ 03 THEN 'Mar' ELSE IF &M2 EQ 04 THEN 'Apr' ELSE IF &M2 EQ 05 THEN 'May' ELSE IF &M2 EQ 06 THEN 'Jun' ELSE IF &M2 EQ 07 THEN 'Jul' ELSE IF &M2 EQ 08 THEN 'Aug' ELSE IF &M2 EQ 09 THEN 'Sep' ELSE IF &M2 EQ 10 THEN 'Oct' ELSE IF &M2 EQ 11 THEN 'Nov' ELSE 'Dec';
-TYPE &MM2;
-SET &MM3 =  IF &M3 EQ 01 THEN 'Jan' ELSE IF &M3 EQ 02 THEN 'Feb' ELSE IF &M3 EQ 03 THEN 'Mar' ELSE IF &M3 EQ 04 THEN 'Apr' ELSE IF &M3 EQ 05 THEN 'May' ELSE IF &M3 EQ 06 THEN 'Jun' ELSE IF &M3 EQ 07 THEN 'Jul' ELSE IF &M3 EQ 08 THEN 'Aug' ELSE IF &M3 EQ 09 THEN 'Sep' ELSE IF &M3 EQ 10 THEN 'Oct' ELSE IF &M3 EQ 11 THEN 'Nov' ELSE 'Dec';
-TYPE &MM3; 


WebFOCUS 7.6.1
Windows, All Outputs
 
Posts: 50 | Location: Scun-thorpe,UK | Registered: November 14, 2012Report This Post
Virtuoso
posted Hide Post
That if statement can be much easier and shorter.

Look at the function DECODE
-SET &MM1= DECODE &M1(1 jan 2 feb 3 mar 4 apr) etc...




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

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Master
posted Hide Post
Even better... you don't even need to move the date 1, 2 or 3 months back.

Just 'jinx' the decodes.

-SET &M = EDIT(&YYMD,'$$$$99$$');
-SET &M_MIN1 = DECODE &M( '01' 'DEC' '02' 'JAN' '03' 'FEB' '04' 'MRC' '05' 'APR' '06' 'MAY' '07' 'JUN' '08' 'JUL' '09' 'AUG' '10' 'SEP' '11' 'OCT' '12' 'NOV'); 
-SET &M_MIN2 = DECODE &M( '02' 'DEC' '03' 'JAN' '04' 'FEB' '05' 'MRC' '06' 'APR' '07' 'MAY' '08' 'JUN' '09' 'JUL' '10' 'AUG' '11' 'SEP' '12' 'OCT' '01' 'NOV'); 
-SET &M_MIN3 = DECODE &M( '03' 'DEC' '04' 'JAN' '05' 'FEB' '06' 'MRC' '07' 'APR' '08' 'MAY' '09' 'JUN' '10' 'JUL' '11' 'AUG' '12' 'SEP' '01' 'OCT' '02' 'NOV'); 

-TYPE &M_MIN1
-TYPE &M_MIN2
-TYPE &M_MIN3


Greets


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Master
posted Hide Post
Nice Dave. All done in just one line. Smiler


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Gold member
posted Hide Post
Thanks FrankDutch.

It is also working for me.


WebFOCUS 7.6.1
Windows, All Outputs
 
Posts: 50 | Location: Scun-thorpe,UK | Registered: November 14, 2012Report 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] Previous 3 month name from a given Date

Copyright © 1996-2020 Information Builders