LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 10 Jun 1996 17:37:57 GMT
Reply-To:   "Glenn H. Itano" <itano@NETCOM.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   "Glenn H. Itano" <itano@NETCOM.COM>
Organization:   Pomoxis Systems
Subject:   Re: # of weekdays between two SAS dates

One more way to do this - 6.07 or later, I think

>In article <>, <GSDIMENT@AM.PNU.COM> wrote: >>A colleague of mine wonders if there is code out there to calculate the >>number of weekdays between two SAS dates. For his purposes, weekdays are >>all days Mon-Fri. In other words, the # of weekdays between two dates >>would be the number of days, minus all Saturdays & Sundays. ...

Use the "weekday" interval with the INTCK function -

weekdays = intck("WEEKDAY",date1,date2);

Note that if date1=date2, this returns a 0. If you want to calculate the number of weekdays between two dates inclusive, you should use

weekdays = 1 + intck("weekday",date1,date2);

I ought to rtfm (or tech report or online help) a bit more often...

You might use the code I posted earlier,

> weekdays = 1 + date2 - date1 /* If start=end, get 1 work day */ > - 2*intck("week",date1,date2) /* subtract 2* #weekends */ > - (weekday(date1)=1) /* subtract 1 if date1 is Sunday */ > - (weekday(date2)=7) /* subtract 1 if date2 is Saturday */ > ;

if you're using an earler version of SAS (pre-6.07).


-- +----------------+------------------+-----------------+---------------------+ | Glenn H. Itano | | Pomoxis Systems | Alameda, California | +----------------+------------------+-----------------+---------------------+

Back to: Top of message | Previous page | Main SAS-L page