Focal Point
Date difference (Working days)

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7831046191

October 18, 2006, 01:12 PM
Adolf Mergulhao
Date difference (Working days)
Is there a function that one can use find the difference between 2 dates but ommit the weekends i.e. Saturdays and Sundays


Webfocus 7.6.2 on Windows Enterprise 2003 Server and
Webfocus 7.6.2 on HP Unix Server
October 18, 2006, 01:16 PM
N.Selph
DATEDIF will do it. You must convert both dates to Smart Dates first.
  
DATEDIF(date_one, date_to, 'WD')



(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
October 18, 2006, 01:21 PM
Francis Mariani
DATEDIF using WD (Weekday):

-SET &DIFF = DATEDIF(20061012, 20061018, 'WD');
-TYPE &DIFF


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
October 18, 2006, 01:24 PM
Francis Mariani
Strangely, the example in the documentation yields the wrong answer:

-SET &DIFF = DATEDIF(19960302, 19970301, 'Y');
-TYPE &DIFF
quote:
DATEDIF calculates the difference between March 2, 1996, and March 1, 1997, and returns a zero because the difference is less than a year
results in 27.


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
October 18, 2006, 05:21 PM
jimster06
Additionally, you can specify workdays by setting up a calendar and holidays according to Chapter 8 in the Functions manual.


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
October 19, 2006, 09:21 AM
Glenda
Setting up the holidays is one I've given up on. We have read and reread Chapter 8. We resorted to an "Include" for the holidays, Has any one set up a "Holidays" file?


Glenda

In FOCUS Since 1990
Production 8.2 Windows
October 19, 2006, 09:45 AM
Adolf Mergulhao
i am more concerned with capturing the working hours as you may work for 2 hours on Friday and Sat and Sun is not counted, but the function only excludes week ends.


Webfocus 7.6.2 on Windows Enterprise 2003 Server and
Webfocus 7.6.2 on HP Unix Server
October 19, 2006, 11:20 AM
N.Selph
As to a holiday file. We have set one up, and it works fine.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
October 19, 2006, 01:29 PM
Adolf Mergulhao
Do you mind leeting me know how to set one up. My email address is adolf.mergulhao@bt.com


Webfocus 7.6.2 on Windows Enterprise 2003 Server and
Webfocus 7.6.2 on HP Unix Server
October 19, 2006, 05:33 PM
N.Selph
Create a file with a date on each line like this for all your holidays:
20030101
20030217
20030418
Use a text editor or create with a focexec from a data source and hold as format ALPHA.
Call it hdayXXXX.err. Substitute any other 4 characters for XXXX. Remember Unix is case sensitive.
Put the file in .../ibi/srv71/wfs/bin (Unix).
Make sure the permissions allow you to overwrite it (if you are going to update it with focexecs).

In your fex that use it you reference it as
SET HDAY = XXXX

Where XXXX is what you used above.

Schedule your focexec that updates the file in Report Caster to run once a year when your data source is updated.


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
October 20, 2006, 10:21 AM
Glenda
Based on the information below, I should be getting a DTDIFF of 5 not 7. Where have I gone wrong?

I have tried it with:

SET HDAY = DOFF
SET HDAY = doff
SET hday = doff


location of holiday file:
/eda53/ibi/srv53/wfs/bin/hdaydoff.err

focexec:
SET HDAY = DOFF
SET BUSDAYS = _MTWTF_
-RUN

TABLE FILE CAR
PRINT
COUNTRY
COMPUTE DAT1/YYMD = 20031220 ;
COMPUTE DAT2/YYMD = 20031231 ;
COMPUTE DTDIFF/I2 = DATEDIF(DAT1, DAT2, 'BD');
END

output:
COUNTRY DAT1 DAT2 DTDIFF
ENGLAND 2003/12/20 2003/12/31 7
JAPAN 2003/12/20 2003/12/31 7
ITALY 2003/12/20 2003/12/31 7
W GERMANY 2003/12/20 2003/12/31 7
FRANCE 2003/12/20 2003/12/31 7


Glenda

In FOCUS Since 1990
Production 8.2 Windows
October 20, 2006, 12:29 PM
N.Selph
I don't know. When I run your code, and my Holiday file, I get 5 days DTDIFF.

In my case the XXXX part is a 4-digit number, so I don't have to worry about case.

I would suspect it either can't find or can't read your holiday file.

We used the same set up in WF 5.21- and it worked without change in the upgrade to 7.13.

This message has been edited. Last edited by: N.Selph,


(Prod: WebFOCUS 7.7.03: Win 2008 & AIX hub/Servlet Mode; sub: AS/400 JDE; mostly Self Serve; DBs: Oracle, JDE, SQLServer; various output formats)
October 23, 2006, 02:07 PM
Francis Mariani
My holiday file (C:\ibi\srv53\wfs\bin\HDAYDOFF.err) contains:

20031224
20031225
20031226

This fex:

SET HDAY = DOFF
TABLE FILE CAR
PRINT
COUNTRY
COMPUTE DAT1/YYMD = 20031220 ; NOPRINT
COMPUTE DAT2/YYMD = 20031231 ; NOPRINT
COMPUTE DAT1I/I8YYMD = DAT1; NOPRINT
COMPUTE DAT2I/I8YYMD = DAT2; NOPRINT
COMPUTE DAT1X/wDMtYY = DAT1;
COMPUTE DAT2X/wDMtYY= DAT2;
COMPUTE DATEDIF1/I4 = DATEDIF(DAT1, DAT2, 'BD');
COMPUTE DATEDIF2/I4 = YMD(DAT1I, DAT2I);
END

gives me 4 for DATEDIF1 and 11 for DATEDIF2 (I'm not sure why function YMD wouldn't use the holday file).

By the way, if the SET command HDAY couldn't find the file, it would return an error. So, check the contents of the holiday file.


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