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] Need help with DATEDIF

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Need help with DATEDIF
 Login/Join
 
Member
posted
Hello

I'm having problems getting the DATEDIF function to work correctly.

This is what I'm trying to do:

I want to calculate the difference between two dates so I thought I could accomplish this with:

-SET &dateDiff = DATEDIF(20100401, 20100402, 'D');

This works as expected and returns a difference of 1 day.

However, if I try the following:

-SET &dateDiff = DATEDIF(20100301, 20100401, 'D');

I would have thought this should return a difference of 31 days, instead it returns 100. I don't know why it does this.

To get around this issue I tried the following:

-SET &dateDiff = DATEDIF('01 MAR 2010', '01 APR 2010', 'D');

This worked correctly and calculated the difference as 31 days. However, I need to pass these dates into the DATEDIF function as variables. The first date is when the report was created, the second the current date. To do this I've used the following:

-* the first date
-SET &startDate = '20100401';

-* get the current date
-SET ¤tDate = TODAY(A10);

-* format the current date
-SET ¤tDate = EDIT(¤tDate,'$$$$$$9999')|EDIT(¤tDate,'99')|EDIT(¤tDate,'$$$99');

-* convert to '01 APR 2010' format
-SET &formatCurrentDate = CHGDAT('YYMD', 'DMYYT', ¤tDate, 'A17');
-SET &formatStartDate = CHGDAT('YYMD', 'DMYYT', &startDate, 'A17');

-* calculate difference
-*SET &dateDiff = DATEDIF(&formatStartDate, &formatCurrentDate, 'D');

When I run this I get the following error:

(FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION DATEDIF

It doesn't appear to like me passing in the date in variables if its of the format '01 APR 2010'

I'm now stumped.

I would be grateful for any assistance you can provide.

Thanks

Micheal

This message has been edited. Last edited by: Kerry,
 
Posts: 12 | Registered: August 17, 2007Report This Post
Virtuoso
posted Hide Post
If you use date strings instead of Smart Dates, function DATEDIF requires separators between the year, month, and day portions of the date string, and single quotes around the entire string. The code below seems to work.

-SET &STARTDATE = '20100401';
-SET &START_DATE = EDIT(&STARTDATE,'9999/99/99');
-SET &DATEDIFF = DATEDIF(&START_DATE.QUOTEDSTRING,&DATEYYMD.QUOTEDSTRING,'D');

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Have a look at this Post

It uses the DATEDIF function, and should work for you.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report 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] Need help with DATEDIF

Copyright © 1996-2020 Information Builders