Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datediff between date not inc Bank hols

Status
Not open for further replies.

Willie78

Technical User
Jun 4, 2004
67
0
0
GB
Hi all

I am trying to workout the difference between 2 dates

Using datediff and exculding weekends and bank holidays.
I have the example below to exclude weekends.

DateTimeVar d1 := {Orders.Order Date};

DateTimeVar d2 := {Orders.Ship Date};

DateDiff ("d", d1, d2) -

DateDiff ("ww", d1, d2, crSaturday) -

DateDiff ("ww", d1, d2, crSunday)

How would i go about excluding specific dates? i.e don't count if 1/5/2006. These aren't stored in the database i'm linking too.

Thanks in advance

Paul
 
Here's one method:
Code:
DateVar Array hol := [Date(2003,12,9),Date(2003,12,11),Date(2003,12,18)];
Local DateVar d1 := Date({Orders.Order Date}) ;
Local DateVar d2 := Date({Orders.Ship Date}) ;

Local NumberVar raw := DateDiff('d',d1,d2) ;
Local NumberVar dys ;
Local NumberVar i ;
For i := 1 to raw do
(
dys := dys + (If (DayOfWeek(d1+i)in [1,7]) OR (d1+i in hol) then 1)
);
raw-dys

Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top