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     [CLOSED] DATEDIF function with variables

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] DATEDIF function with variables
 Login/Join
 
Member
posted
Hi All,

This might seem bit silly, but I am not able to get diff between dates.
Code is-
  
-SET &START_DATE = '2008/05/01';
-SET &END_DATE = '2008/07/31';
-SET &DATED = DATEDIF(&END_DATE, &START_DATE, 'D');
-TYPE &DATED


I get error-
(FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION DATEDIF

Please help.

Thanks!

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


Thanks and Regards,
Piscian

WebFocus 714
Windows Server 2003
Enterprise Edition
HTML,Excel,PDF
 
Posts: 15 | Registered: June 04, 2007Report This Post
Guru
posted Hide Post
My copy of (Almost ) 1001 Ways to Work with DATES in WebFOCUS contains the following passage about DATEDIF ..."It does not curently work with Dialogue Manager variables." p 289.
And I highly recommend the book.
Here is a definitive discussion.
edit to add URL

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


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Virtuoso
posted Hide Post
You can use DATEDIF in dialog manager -SET, with amper vars as the date arguments, provided you apply .QUOTEDSTRING to them:

Code:
-SET &DT1='2008/05/01';
-SET &DT2='2008/07/31';
-SET &DT3=DATEDIF( &DT1.QUOTEDSTRING, &DT2.QUOTEDSTRING, 'D');
-SET &DT4=DATEDIF( &DT1.QUOTEDSTRING, &DT2.QUOTEDSTRING, 'WD');
-SET &DT5=DATEDIF( &DT1.QUOTEDSTRING, &DT2.QUOTEDSTRING, 'M');

-? &DT


Result:
 CURRENTLY DEFINED & VARIABLES STARTING WITH 'DT':
 &DT1          = 2008/05/01
 &DT2          = 2008/07/31
 &DT3          = 91
 &DT4          = 65
 &DT5          = 2


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
You can also use AYMD if you take out the slashes.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
Jack,

You seriously have a secret horde of great WebFOCUS tips that are stored outside the box!

I bet this is not documented anywhere - QUOTEDSTRING is only discussed for embedded single-quotes.

Thanks for the tip.


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
quote:
QUOTEDSTRING is only discussed for embedded single-quotes

Which is why you could also code it like:
-SET &DT1='2008/05/01';
-SET &DT2='2008/07/31';
-SET &DT3=DATEDIF( '&DT1.EVAL', '&DT2.EVAL', 'D');
-SET &DT4=DATEDIF( '&DT1.EVAL', '&DT2.EVAL', 'WD');
-SET &DT5=DATEDIF( '&DT1.EVAL', '&DT2.EVAL', 'M');
-? &DT

This will produce the same results.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
Interesting Jack. I'll have to try that one. Another way to get this to work is to use the DATECVT function first (like DATECVT(&YYMD,'I8YYMD','YYMD') and then use DATEDIF on those converted dates. Works for DATEADD as well which also "cannot be used with Dialogue Manager."

-SET &AUTO_DATE=DATECVT(DATEADD(DATECVT(&YYMD,'I8YYMD','YYMD'), 'D', -7),'YYMD','A8YYMD');


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Expert
posted Hide Post
I've always used the DATECVT method, but this is so much more elegant:
-SET &DT6A = DATEADD(&YYMD.QUOTEDSTRING, 'D', -7);
And, as GamP points out,
-SET &DT6B = DATEADD('&YYMD.EVAL', 'D', -7);
works as well. Why didn't I think of that? No need for the DATECVT function in DM any more.


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
FM --

Not so fast. (Try those with +61 instead of -7 Wink )

The input is required to represent a "smart" date (accepted in either offset integer form or formatted date form), and the output is an offset integer. &YYMD, even with the quotes, is interpreted as an offset of +yy,yym,mdd.

Bottom line -- use a formatted value (&DATEYYMD rather than &YYMD), and apply DATECVT to the result to obtains a displayable date.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Yikes! Just found this update after seeing Tony's posting about DATEMOV, I'll be sticking with the DATECVT option, thank you.


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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] DATEDIF function with variables

Copyright © 1996-2020 Information Builders