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] Date format question

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Date format question
 Login/Join
 
Master
posted
Is there a date/?? format for May-14 (May 2014)?


Thank you

This message has been edited. Last edited by: FP Mod Chuck,


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Master
posted Hide Post
If you use DATE/MtY it will give you the format May, 14. If you need to change the delimiter, then check out the docs on DATETRAN

IMHO, the docs aren't very clear, and are really hard to follow However, I was able to get it to the format you requested in the sample fex below
 
DEFINE FILE ggsales
DATE1/MtY = DATE;
DATE2/A6 = DATETRAN(DATE1, '(MY)','(-t)', 'EN', 6, 'A6');
END
TABLE FILE ggsales
BY DATE
BY DATE1
BY DATE2
END
 


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
 
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Report This Post
Master
posted Hide Post
Looks like this works as well
  
DEFINE FILE ggsales
Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
END
TABLE FILE ggsales
BY DATE
BY Month-Year
END


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
 
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Report This Post
Master
posted Hide Post
LOL... I'm always on a quest to shorten the lines of code 🤓
  
TABLE FILE ggsales
SUM COMPUTE Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY DATE
END


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
 
Posts: 608 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Hallway:
LOL... I'm always on a quest to shorten the lines of code 🤓
  
TABLE FILE ggsales
SUM COMPUTE Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY DATE
END


The above does work because you only have the BY DATE, but if it is as below, only one date from each CITY will be displayed and depending one data organization it may be any one.
So, when using a COMPUTE to shorten the lines of code you need to pay attention at the result and desired result.

TABLE FILE ggsales
SUM COMPUTE Month-Year/A6 = DATETRAN( DATECVT( DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY CITY
-*BY DATE
END


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Master
posted Hide Post
Thank you MartinY and Hallway. With a clear mind I came up with this:


TABLE FILE EMPLOYEE
PRINT
COMPUTE MONTH4/Mt = HIRE_DATE;
COMPUTE THEMONTH/A3 = FPRINT(MONTH4, 'Mt', 'A3');
COMPUTE YEAR2/Y = HIRE_DATE;
COMPUTE YR/A2 = EDIT(YEAR2);
COMPUTE HDDATE/A10 = THEMONTH || '-' || YR;

BY EMPLOYEE.EMPINFO.HIRE_DATE
ON TABLE NOTOTAL
ON TABLE SET STYLE *
$
ENDSTYLE
END


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Virtuoso
posted Hide Post
@Tomsweb

Just a question : why not have used Hallway simplified coding ? Much less lines of code...

TABLE FILE EMPLOYEE
PRINT COMPUTE HDDATE/A10 = DATETRAN( DATECVT( HIRE_DATE, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');
BY EMPLOYEE.EMPINFO.HIRE_DATE
ON TABLE NOTOTAL
ON TABLE SET STYLE *
$
ENDSTYLE
END


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Master
posted Hide Post
His code is fine. I was just trying to take initiative. I can certainly use his code .


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Virtuoso
posted Hide Post
quote:
Originally posted by Tomsweb:
I was just trying to take initiative.


This is perfect but you should also take initiative to simplify and optimize your code.

Having 5 COMPUTEs and 4 functions (FPRINT, EDIT and twice the double pipe) used is less efficient than 1 COMPUTE and 2 functions Big Grin

Just me 2 cent


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Gold member
posted Hide Post
Here is a third way to do this:

INDATA/A8YYMD WITH DVAL = '&YYMD' ;
MYM/A2 = EDIT(INDATA,'$$$$99');
MYMT/A3 = DECODE MYM(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun
                     07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ???);
MYD/A2 = EDIT(INDATA,'$$99');
MYMYR/A6 = MYMT | '-' | MYD ;
 


This technique uses no functions (EDIT is not really a function, but rather a compiled construct).

Just for fun, here is a benchmark that compares all three techniques for efficiency:

-DEFAULTS &FLD=MYEAR,&RECLIM=20000
DEFINE FILE SMALL
INDAT/I8YYMD WITH DVAL = &YYMD;
INDATA/A8YYMD WITH DVAL = '&YYMD' ;
INA/A6       WITH DVAL = 'Aug-19';
INYYMD/YYMD  WITH DVAL = &YYMD;
MYEAR/A6 = DATETRAN( DATECVT ( INDAT, 'I8YYMD', 'MY' ), '(MY)', '(-t)', 'EN', 6, 'A6');

MONTH4/Mt = INYYMD;
THEMONTH/A3 = FPRINT(MONTH4, 'Mt', 'A3');
YEAR2/Y = INYYMD;
YR/A2 = EDIT(YEAR2);
HDDATE/A10 = THEMONTH || '-' || YR;

MYM/A2 = EDIT(INDATA,'$$$$99');
MYMT/A3 = DECODE MYM(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun
                     07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ???);
MYD/A2 = EDIT(INDATA,'$$99');
MYMYR/A6 = MYMT | '-' | MYD ;
END
-RUN

-TYPE First, get the base benchmark.
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM INA
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU BASE: &DIFF

-TYPE Now, the MYEAR technique:
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM MYEAR
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU MYEAR: &DIFF
-TYPE Next, the HDDATE technique:
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL
SUM HDDATE
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU HDDATE: &DIFF

-TYPE Finally, the MYMYR technique (no functions)
-SET &MYCPU = &FOCCPU ;
TABLE FILE SMALL     
SUM MYMYR
IF RECORDLIMIT EQ &RECLIM
END
-RUN
-SET &DIFF = &FOCCPU - &MYCPU ;
-TYPE CPU MYMYR: &DIFF
 


The SMALL file is just a file with 20000 short records, with the DVAL field in the segment that has 20000 records. You can substitute your own SMALL file with your own 'WITH' field, and the benchmark will work.

Here is the result on a zos mainframe:
>>ex test
First, get the base benchmark.
 PAGE     1
 
 
 INA                                                                           
 ---                                                                           
 Aug-19
 
 
CPU BASE: 59 
Now, the MYEAR technique:  
 PAGE     1
 
 
 MYEAR                                                                         
 -----                                                                         
 Aug-19
 
 
CPU MYEAR: 147 
Next, the HDDATE technique:  
 PAGE     1
 
 
 HDDATE                                                                        
 ------                                                                        
 Aug-19    
 
 
CPU HDDATE: 139 
Finally, the MYMYR technique (no functions)  
 PAGE     1
 
 
 MYMYR                                                                         
 -----                                                                         
 Aug-19
 
 
CPU MYMYR: 56 
 


So, what does this tell us? The base benchmark is 59ms. This represents the overhead of reading the file, collecting the alpha value, and printing the report. It essentially does nothing.

The MYEAR technique took 147ms total, and subtracting the base, about 88ms.
The HDDATE benchmark took 139ms total, or about 80ms.
The MYMYR benchmark took 56ms total, or, wait- it was *faster* than the base! This happened because in reality, the MYMYR overhead is essentially unmeasureable compared to the base, and is smaller than the normal benchmark variation from one execution to the next. Probably, MYMYR is dozens if not hundreds of times faster than the other two techniques.

So, why is MYMYR so fast? Because it does not use any functions, and the DEFINE code is actually compiled into very fast native zos instructions without any subroutine calls.

So, in general, if you *really* want fast code, avoid function calls and just use FOCUS computations.


IBI Development
 
Posts: 61 | Registered: November 15, 2005Report 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] Date format question

Copyright © 1996-2020 Information Builders