cstraim
asked on
Excel NetworkDays function for Access
Does anyone know how to make a function for SQL that will behave the same way as Excel's networkdays. Here is my excel formula
=IF(K125=TODAY(),0,NETWORK DAYS(K125, TODAY()-1) )
Note* If K125 = 03/28/07 which is today, so the result would be 0 or If K125=03/26/07, the result would be 2
=IF(K125=TODAY(),0,NETWORK
Note* If K125 = 03/28/07 which is today, so the result would be 0 or If K125=03/26/07, the result would be 2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
also, see this link
http://www.mvps.org/access/datetime/date0012.htm
http://www.mvps.org/access/datetime/date0012.htm
Declare @aDate datetime,
@bDate datetime
Set @aDate = '4/22/2005'
Set @bDate = '5/12/2005'
Select
dayDiff = datediff(dy,@aDate,@bDate)
fullweeks = datediff(dy,@aDate,@bDate)
weekdays = datediff(dy,@aDate,@bDate)
startday = datepart(dw,@aDate),
extraDays = datediff(dy,@aDate,@bDate)
estraWeekDays = case
when datepart(dw,@aDate)=1 and datediff(dy,@aDate,@bDate)
when datepart(dw,@aDate)>1 and datepart(dw,@aDate)+datedi
when datepart(dw,@aDate)>1 and datepart(dw,@aDate)+datedi
else 0 end,
weekdayDiff = datediff(dy,@aDate,@bDate)
case when datepart(dw,@aDate)=1 and datediff(dy,@aDate,@bDate)
when datepart(dw,@aDate)=1 and datediff(dy,@aDate,@bDate)
when datepart(dw,@aDate)>1 and datepart(dw,@aDate)+datedi
when datepart(dw,@aDate)>1 and datepart(dw,@aDate)+datedi
else 0 end)