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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DaysInMonth() 1

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
Is there a way any of you know to tweak the DaysInMonth() function to give the number of workdays in that month? In other words, not count the weekends. Kevin
slanek@ssd.fsi.com
 
this question has been asked a few days ago
i don't remember if it was in this forum or in the javascript ? html & css ? one ...
 
Cool. Thanks iza. I'll do some searching. Kevin
slanek@ssd.fsi.com
 
Hey Kevin,

I remember a post on March 8 where I posted some code to do something similar. This should give a reasonable accurate number for you. It starts with the day after sDate and counts days up to and including eDate.

<cfset workDays=0>
<cfloop index=&quot;x&quot; from=1 to=#datediff(&quot;d&quot;,sDate,eDate)#>
<cfif dayofweek( dateAdd(&quot;d&quot;,x,sDate)) neq 1 and dayofweek(
dateAdd(&quot;d&quot;,x,sDate)) neq 7>
<cfset workDays=workDays + 1>
</cfif>
</cfloop>

Hope this helps,
GJ
 
So, if DayOfWeek is a 1 or a 7 it is a Sunday and Saturday (respectively)? Am I reading it correctly? Kevin
slanek@ssd.fsi.com
 
That's correct. I think the only thing to watch out for is how it treats the starting and ending days. Currently, the starting date is not counted and the ending date is counted. You can easily modify the code to alter this but I just coded it this way because it was less complicated.

GJ
 
Cool. That should work out really well. Thanks! Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top