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 calculation works differently in mfd than in the fex

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Date calculation works differently in mfd than in the fex
 Login/Join
 
Silver Member
posted
I've got a fairly standard date calculation set up in a master file, since I use it in a few different places. It's defined as such:
DATEDIF(HDATE( field_name,'YYMD'),&YYMD,'D')

It works excellently as defined in the master file.

However, if the exact same formula is used as a compute or define in a fex, the fex-used code comes up with a bad result. Example, 20 million (or so) instead of 6000 (or so). I can't seem to find any correlation between the two numbers, or any reason why the same calculation should work differently. Has anyone got any experience with something like this?

This message has been edited. Last edited by: Keith MacDonald,


WebFOCUS & DataMigrator 7.7.03M
Windows 2003, Windows 2008 x64
 
Posts: 35 | Registered: May 11, 2011Report This Post
Expert
posted Hide Post
Is it possible that the calculated number of days is an aggregated value and that's why you're getting 20 million instead of 6000? I.E. there are multiple input rows with the same date...

If there are joins, is the same column name in another table in the joined structure?


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
Look at the Help page (in Dev Studio) for DATEDIF, including the examples provided. If either date argument of DATEDDIF() is a constant, it must be put in quotes.

If you omit the quotes, and code
DIFF/I9=DATEDIF( HDATE(my_datetime_field,'YYMD'), &YYMD,'D');
in a fex, the line placed in focstack and executed (today) is
DIFF/I9=DATEDIF( HDATE(my_datetime_field,'YYMD'), 20110713,'D');

Since DEFINE knows that a ("smart") date field is expected, and such fields internally hold integer offsets from a base date around 1900, 20110713 is interpreted as the date 20,110,713 days beyond the base date. Need I say more?

With quotes:
DIFF/I9=DATEDIF( HDATE(my_datetime_field,'YYMD'), '&YYMD','D');
-- the line resolves to
DIFF/I9=DATEDIF( HDATE(my_datetime_field,'YYMD'), '20110713','D');
The quoted numeric string '20110713' is understood, in this context. as representing the date 2011-07-13, and the offset of that date is used.

For a define in the mfd, different logic takes hold (the &YYMD there never gets subject to the substitution & stacking process of lines in a fex). &YYMD gets replaced by a proper date variable initialized to the current date, and all is well. But in a fex you must supply the quotes.

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
Beautiful, clear, explanation. Nicely done.


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
Master
posted Hide Post
quote:
Originally posted by George Patton:
Beautiful, clear, explanation. Nicely done.


+1 Great explanation Jack.


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Silver Member
posted Hide Post
Agreed very well put. Thank you Jack for the explanation!


WebFOCUS & DataMigrator 7.7.03M
Windows 2003, Windows 2008 x64
 
Posts: 35 | Registered: May 11, 2011Report 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 calculation works differently in mfd than in the fex

Copyright © 1996-2020 Information Builders