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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
DATEDIF Issues
 Login/Join
 
Member
posted
I am currently trying to put together a defined column to calculate the number of days between two dates. I have the following...

TESTING/I8=DATECVT(EDIT('01/01/2013','99$99$9999'),'A8MDYY','I8');
TESTING2/I8=DATECVT(EDIT('07/09/2013','99$99$9999'),'A8MDYY','I8');

DAYSAPART/I8=DATEDIF(TESTING,TESTING2,'D');

TESTING is coming back as 43772630
TESTING2 is coming back as 43974860
DAYSAPART is coming back as 202230

Obviously this is incorrect. Can someone please tell me what I am doing wrong here? I have tried this numerous different ways, and the final result is always the same (number of days * 1070).

Thanks,

Dan


WebFOCUS 7703
 
Posts: 13 | Registered: June 11, 2013Report This Post
Silver Member
posted Hide Post
DATEDIF uses full component date. Try:

TESTING/YYMD=DATECVT(EDIT('01/01/2013','99$99$9999'),'A8MDYY','YYMD');
TESTING2/YYMD=DATECVT(EDIT('07/09/2013','99$99$9999'),'A8MDYY','YYMD');
DAYSAPART/I8=DATEDIF(TESTING,TESTING2,'D');


Year(s) of experience in WebFOCUS: 5+. Using WebFOCUS 7.7.03 on Windows platform with Oracle/SQL Server.
 
Posts: 41 | Registered: September 08, 2008Report This Post
Member
posted Hide Post
I am still getting the same results using the following, which was suggested.

MINDATEFORYEARSTR/A20='01/01/2013';
TODAYYY/YY=&DATEYY;
MAXDATEFORYEARSTR/A20=IF TODAYYY EQ &SEPARATIONYEAR THEN TODAY('A10') ELSE '12/31/'|&SEPARATIONYEAR.EVAL;

TESTING/YYMD=DATECVT(EDIT(MINDATEFORYEARSTR,'99$99$9999'),'A8MDYY','YYMD');
TESTING2/YYMD=DATECVT(EDIT(MAXDATEFORYEARSTR,'99$99$9999'),'A8MDYY','YYMD');

DAYSAPART/I8=DATEDIF(TESTING,TESTING2,'D');

MINDATEFORYEARSTR - '01/01/2013'
MAXDATEFORYEARSTR - '07/09/2013'
TESTING - '2013/01/01'
TESTING2 - '2013/07/09'
DAYSAPART - 202230

Any other ideas?

Thanks!


WebFOCUS 7703
 
Posts: 13 | Registered: June 11, 2013Report This Post
Virtuoso
posted Hide Post
quote:
MAXDATEFORYEARSTR/A20=IF TODAYYY EQ &SEPARATIONYEAR THEN TODAY('A10') ELSE '12/31/'|&SEPARATIONYEAR.EVAL;


[Edited] SEPARATIONYEAR is presumably a database variable, rather than a report parameter, so make that

MAXDATEFORYEARSTR/A20=IF SEPARATIONYEAR EQ TODAYYY THEN TODAY('A10') ELSE '12/31/' | SEPARATIONYEAR;

This message has been edited. Last edited by: j.gross,
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Are the dates always strings, are they only date or date time ?

You should be able to convoert them the Smart dates, and then just subtract them to get the number of days.


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
Silver Member
posted Hide Post
Dan,
Your example implies that you are starting with date data stored as a string. On that basis I created the following test.
-* File test.fex
SET ONLINE-FMT=PDF
DEFINE FILE DATETIME
DATESTRING1/A10 = '01/01/2013' ;
DATESTRING2/A10 = '07/09/2013' ;
DATESTRING3/A8MDYY = EDIT(DATESTRING1,'99$99$9999') ;
DATESTRING4/A8MDYY = EDIT(DATESTRING2,'99$99$9999') ;
DATESMART_1/MDYY = DATESTRING3 ;
DATESMART_2/MDYY = DATESTRING4 ;
DAYSDIFF/I6 = DATESMART_2 - DATESMART_1 ;
END
TABLE FILE DATETIME
PRINT SD_MDY1 NOPRINT
DATESTRING1 IN +1 DATESTRING2 OVER
DATESTRING3 IN +1 DATESTRING4 OVER
DATESMART_1 IN +1 DATESMART_2 IN +2
DAYSDIFF IN +1
IF RECORDLIMIT EQ 1
END
-RUN
DATESTRING1 & 2 are simple string values.
DATESTRING3 & 4 convert these to legacy dates
DATESMART_1 & 2 convert the legacy dates to SmartDates
SmartDates are internally stored as days elapsed from 1901
DAYSDIFF simply subtracts to get the days between the dates (result is 189 days).
DATESTRING1 01/01/2013 DATESTRING2 07/09/2013
DATESTRING3 01/01/2013 DATESTRING4 07/09/2013
DATESMART_1 01/01/2013 DATESMART_2 07/09/2013 DAYSDIFF 189
The DTxxx and DAxxx functions can also be used to accomplish this. Given the rich set of date functions in FOCUS, I'm sure there are several other methods as well.
All of this and more can be found in:
(Almost) 1001 Ways to Work with Dates in WebFOCUS - available at www.Aviter.com.

This message has been edited. Last edited by: John W Price,



WebFOCUS 8.0.2, FOCUS since 1977 - John@Aviter.com
PDF , Excel, FOCUS, Author of the Keysheets and Dates book.
www.Aviter.com
 
Posts: 40 | Registered: April 19, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders