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     calculate difference in dates

Read-Only Read-Only Topic
Go
Search
Notify
Tools
calculate difference in dates
 Login/Join
 
<B_B>
posted
Hi,
I need to calculate difference in Start_Date
& End_date in output format like 'x Days y Hrs and z Mins'.

The Strat_Date & End_Date have format like HYYMDs.

I am able to find difference for 'x Days and y Hrs' but not for calculating 'Mins'. I am getting mins like 500 ,535 etc. Ideally it should be 20 mins etc(only 2 digits).
I am using HDIFF() function for that.

e.g.result/D6 = HDIFF(end_date,start_date,'MINUTE','D6') ;

Please suggest.
 
Report This Post
Expert
posted Hide Post
Take the result of your difference in minutes and apply basic maths to work out how many days, hours and minutes.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
<B_B>
posted
Thnx for ur reply Tony!

I did the same and divided the mins by 60.
e.g. 535\60 = 5.883333

I will get 5 hrs...but how do i pull the mins(using which func?)

Please suggest.
 
Report This Post
Expert
posted Hide Post
DEFINE FILE CAR
BEGDTA/A20='20080910103000000';
ENDDTA/A20='20080910103500000';
BEGDT/HYYMDS=HINPUT(14,BEGDTA,8,'HYYMDS');
ENDDT/HYYMDS=HINPUT(14,ENDDTA,8,'HYYMDS');
DIFF_MIN/D6=HDIFF(ENDDT,BEGDT,'MINUTE','D6');
END
TABLE FILE CAR
PRINT BEGDTA BEGDT ENDDTA ENDDT DIFF_MIN
BY COUNTRY
END

Your code looks correct. Please check your data. In the sample above, I get 5 minutes which is the answer I was expecting.


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
BB,

You just have to think about the basic maths behind your request.

You have minutes.
Hours is the integer of minutes / 60 as you have it, but first you need to do days? So .....

Days is the integer of minutes divided by minutes in a day - there are 60 minutes and 24 hours so your maths would be .......

Once you have the days, take the number of minutes in that number of days away from your minutes total to give you the number of minutes remaining.

Now work out the hours and again get the remainder, that becomes the minutes.

Simple, if you only think about it.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
<JG>
posted
Using Ginny's code as a basis

DEFINE FILE CAR
BEGDTA/A20='20080910103000000';
ENDDTA/A20='20080911135500000';
BEGDT/HYYMDS=HINPUT(14,BEGDTA,8,'HYYMDS');
ENDDT/HYYMDS=HINPUT(14,ENDDTA,8,'HYYMDS');
DIFF_MIN/D6=HDIFF(ENDDT,BEGDT,'MINUTE','D6');
DAYS/D2=INT(DIFF_MIN/1440);
HOURS/D2=INT((IMOD(DIFF_MIN, 1440, 'D20.2')/60));
MINS/D2=DIFF_MIN - (DAYS * 1440) - (HOURS * 60);
DAYT/A6= IF DAYS EQ 1 THEN ' Day ' ELSE ' Days ';
HRT/A7= IF HOURS EQ 1 Then ' Hour ' ELSE ' Hours ';
MINT/A8= IF MINS EQ 1 THEN ' Minute ' ELSE ' Minutes';
DIFFERENCE/A30= TRIM('L', EDIT(DAYS), 2, '0', 1, 'A2') | DAYT |
TRIM('L', EDIT(HOURS), 2, '0', 1, 'A2') | ' Hours ' |
TRIM('L', EDIT(MINS), 2, '0', 1, 'A2') | ' Minutes';
END
TABLE FILE CAR
PRINT BEGDTA BEGDT ENDDTA ENDDT DIFFERENCE
BY COUNTRY
END
If you want leading zero's just use a plain edit and remove trhe TRIM

This message has been edited. Last edited by: <JG>,
 
Report 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     calculate difference in dates

Copyright © 1996-2020 Information Builders