Desktop productivity for business analysts and programmers

How to find the difference between two days excluding holidays

Reply
Contributor
Posts: 51

How to find the difference between two days excluding holidays


I am trying to find the diff between two dates excluding weekends using intck ('weekday',date 1, date2) however i need to know how to exclude the below holidays between

the dates

Value Amerhol

                            '24Dec2013'D,

                            '25Dec2013'D,

                            '31Dec2013'D,

                            '1Jan2014'D = 1

OTHER=0;

Frequent Contributor
Posts: 106

Re: How to find the difference between two days excluding holidays

Hi , Try this. it excludes weekends and holidays.

data holiday;

input holiday date9.;

cards;

24Dec2013

25Dec2013

31Dec2013

01Jan2014

;

data real_date;

input real_date date9.;format real_date date9.;

cards;

20Dec2013

21Dec2013

22Dec2013

23Jan2013

24Dec2013

25Dec2013

26DEC2013

27DEC2013

28DEC2013

29DEC2013

30Dec2013

31DEC2013

01JAN2014

02JAN2014

05JAN2014

10JAN2014

12JAN2014

14JAN2014

15JAN2014

;

proc sql noprint;

select holiday into :holiday separated by ',' from holiday;

quit;

data test;

set real_date(where=(weekday(real_date) not in (1,7) and real_date not in (&holiday.)));

Diff=intck('day','14JAN2014'd,real_date);

run;

Contributor
Posts: 51

Re: How to find the difference between two days excluding holidays

Thank you Pradeep. What i am needing is that the date range will be in fiscal week : for ex :- fiscal week 201440 ( nov'13 ) till fiscal week 201448 ( dec'13) my question is do i need to list each day?

i am having a calculated function  intck ('weekday',date 1, date2) which is giving the working days between fiscal week 201440 ( 2nd nov'13 ) till fiscal week 201448 ( 3rdJan'14). for the same date range i need to calculate the working days without holidays below.

11Nov2013

22Nov2013

23Nov2013

24Dec2013

25Dec2013

1Jan2014

Community Manager
Posts: 2,692

Re: How to find the difference between two days excluding holidays

Here's a SAS function that can do the work.

Calculating the number of working days between two dates - The SAS Dummy

Chris

Frequent Contributor
Posts: 106

Re: How to find the difference between two days excluding holidays

you need 2 different dates in some form, if you want to compare/find difference between them.

you can loop through the date range between your fiscal weeks( start date to your end date), then you don't have to list each day.

Ask a Question
Discussion stats
  • 4 replies
  • 2051 views
  • 6 likes
  • 3 in conversation