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] DATEDIF I've tried but now need help with Calculating # of Business Days

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] DATEDIF I've tried but now need help with Calculating # of Business Days
 Login/Join
 
Gold member
posted
Hi,
Been working on this for a few days but now at the point need some fresh ideas on how to proceed!

1. Requirement: Calculate the total # of business days between two dates (inclusive of start date ) i.e.
Total # of business days between Mon - Fri would be 5.

2. SET COMMANDS
BUSDAYS = _MTWTF_
HDAY = FY09 (Have holiday file set up with the Federal Holidays for 2007 - 2010)

3. Problem:
Using the function DATEDIF(from_date,to_date,'BD') returns 4 as the # of business days for a
Monday-Friday time period.

Example:

DATEDIF(04/20/2009,04/24/2009,'BD') = 4. For my requirment I need to show 5 total business days.


4. Possible Solution:
As a possible solution I modify the above funtion to read:

DATEDIF(04/20/2009,04/24/2009,'BD) +1 In this example the function returned: 5


5. Problem (cont). When executing using the following dates the function returns 6 Business days instead of 5 business days.

DATEIF(04/20/2009,04/25/2009)

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


7.7.02 Windows7
HTML/Excel/PDF
 
Posts: 66 | Registered: April 16, 2008Report This Post
Expert
posted Hide Post
Jeff,

Your Holiday file is in YYYYMMDD format, "hopefully", and, your DATEDIF pramaeters are in MM/DD/YYYY format.

Make them the same, YYYYMMDD...

DATEDIF('20090420', '20090425', 'BD')

Just a thought...

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
<JG>
posted
Jeff Your dates are in SMARTDATE formmat and not a legacy format aren't they?
 
Report This Post
Virtuoso
posted Hide Post
DATEDIF() counts the start-date but not the end-date

For example, I get
Sun to Thu = 3 business days [M T W],
Tue to Sat = 4 business days [T W Th F].

-- So just extend the range by one day (add 1 to the end-date).


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
quote:
YYYYMMDD...

I'm a little confused when it comes to SmartDATE vs Legacy format.

Here is what I'm trying to use to test the calculation for Business days

SET HDAY = FY09 Holiday file format YYYYMMDD
SET BUSDAYS = _MTWTF_
DT5/YYYYMD='20090420'
DT6/YYYYMD='20090424'
DT7/YYYYMD='20090420'
DT8/YYYYMD='20090425'

TRNG_DAYS1/I5=(DATEDIF(DT5, DT6, 'BD'))+1;
TRNG_DAYS2/I5=(DATEDIF(DT7, DT8, 'BD'))+ 1;

When I execute I get the following results

TRNG_DAYS1=5 Which is what I want
TRNG_DAYS2=6 This should equal 5 since 04/25/09 is a Saturday.


7.7.02 Windows7
HTML/Excel/PDF
 
Posts: 66 | Registered: April 16, 2008Report This Post
Virtuoso
posted Hide Post
Did we cross in the mail?

What I'm suggesting is
... =DATEDIF(DT5, DT6+1, 'BD');
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
By the way,
.../YYYYMD
should be
.../YYMD


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
And without quotes.


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
Virtuoso
posted Hide Post
quote:
Originally posted by GinnyJakes:
And without quotes.


That "works", but runs against the documentation:

Writing Date Expressions
A date expression can consist of: 

[a] A date constant enclosed in quotation marks. For example:
COMPUTE STARTDATE/MDYY = 'FEB 28 1999' ;

[b] A calculation that uses numeric operators, date functions, or date subroutines to return a date. For example:
DEFINE DELIVERY/MDY = SHIPDATE + 5 ;

[c] A calculation that uses numeric operators, date functions, or date subroutines to return an integer that represents the number of days, months, quarters, or years between two dates. For example:
COMPUTE TURNAROUND/I4 = MDY (ORDERDATE, SHIPDATE) ;


As I see it,
20091231
is an integer expression not involving Date fields or Date-valued functions, so it falls under [c], and should yield a date 20,091,231 days beyond the epoch date. (The fact that the implementation nonetheless treats it as a yyyymmdd date value, rather than assigning an absurd date well beyond year 9999, is no guarantee of future behavior.)

OTOH,
'20091231'
is a valid date constant (in the context of assignment to a /YYMD field) and falls under [a], so it's perfectly safe to use.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
Thanks to all. My report is calculating the # of business days correctly now.

Jeff


7.7.02 Windows7
HTML/Excel/PDF
 
Posts: 66 | Registered: April 16, 2008Report 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] DATEDIF I've tried but now need help with Calculating # of Business Days

Copyright © 1996-2020 Information Builders