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 difference Calculation

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]Date difference Calculation
 Login/Join
 
Member
posted
Hi,
I want to calculate the difference between two dates and the result should be in Months with values upto two decimal places.

If I am using the "DATEDIF" Function then it is truncating the results and not provinding the results updo two decimal places.

Can you please suggest any function available in webfocus 7.6.11 Version.
Thanking you.

This message has been edited. Last edited by: Mayank Agrawal,


7.6.11, Windows
Excel, HTML,PDF
 
Posts: 28 | Registered: April 11, 2011Report This Post
Expert
posted Hide Post
I don't think you can work with decimals and dates. What does 1.2 months mean? You could extract days or hours or smaller measures and do the division yourself...


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
Expert
posted Hide Post
quote:
What does 1.2 months mean


True!

What is a month ?, 31, 30, 28 days ?, 365 / 12 days ?, 365.25 / 12 days ?

Also what code did you use ?


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
Member
posted Hide Post
Francis I agree with you that it does not mean to have month like 1.2, but this is our business requirement.
We have to first calculate the month and then find out the average of all the records.
If I am using DATEDIF function,the result deviated from its actual value.

Also I have thought of first finding the number of days and then dividing by 30.4, but its a kind of approximate method.
If you find any solution please let me know.

Many Thanks.


7.6.11, Windows
Excel, HTML,PDF
 
Posts: 28 | Registered: April 11, 2011Report This Post
Expert
posted Hide Post
You could base the decimal portion on a list of (days in months). and go from there.

(days in month list) = (1 31 2 28 3 31...) with an offset for leap year. Use (day of month) in you calculation with the associated days from your list...

I hope this helps. Smiler
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Master
posted Hide Post
When we have to do this, this is how we do it:
MONTHS/D8.2=(HIGH_DATE-LOW-DATE)/30.4375;


This truncates to 2 digits.

If you want automatic rounding use the P format.

According to the documentation, using HDIFF requires using a D format (Floating Point Double Precision). All the examples show D12.2. However, it does not return fractions either. I asked IBI why have the 2 decimals if they are never used? They did not know so I put in a NFR. So that existing code would not be changed, I suggested using FDAY, FYEAR, etc. in the types for fractional days, years, etc.

It is in "Product Division" whatever that means. If you have a use for fractional date/time computations with DATEDIF or HDIFF, please do a NFR.

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


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
If you're coding a fractional month to a specific business requirement, then that business unit needs to provide you with their official calculation method.

It may be as simple as number of days divided by 30, it may be some strange arcane thing based on the phase of the moon. Regardless, that business unit calls the tune on their expected value. Contact them and ask for the official version. Without it you'll never clear their testing.

J.



 
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007Report 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 difference Calculation

Copyright © 1996-2020 Information Builders