J_Y_C Posted March 20, 2007 Share Posted March 20, 2007 (edited) In Excel, there is a function called "NETWORKDAYS()" that tells you the difference between two day excluding the weekend. I couldn't find anything like this built into AutoIt so I added my own: #include <Date.au3> Func _networkDays($date1, $date2);takes in YYYY/MM/DD $dayDiff =_DateDiff('D',$date1,$date2) if ($dayDiff>0) Then $dt1arr =StringSplit($date1,"/") $dt2arr =StringSplit($date2,"/") $betweenDays = $dt2arr[3]-$dt1arr[3] for $wkendChk = 1 to $betweenDays-1 If ((_DateToDayOfWeek ( $dt1arr[1], $dt1arr[2], $dt1arr[3]+$wkendChk )=1) or (_DateToDayOfWeek ( $dt1arr[1], $dt1arr[2], $dt1arr[3]+$wkendChk )=7)) then $dayDiff-=1 EndIf Next Return $dayDiff Else Return $dayDiff EndIf EndFunc Func _MMDDYYYYtoYYYYMMDD($d) $da = StringSplit($d,"/") if ($da[0]=3) Then return $da[3] & "/" & $da[1] & "/" & $da[2] Else SetError(1) MsgBox(0,"ERROR","Invalid date format") EndIf EndFunc Oh, and if you're like me and used to using MM/DD/YYYY instead of YYYY/MM/DD, I included a little function for that also. I hope this is useful to someone! Edited March 20, 2007 by J_Y_C Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted March 20, 2007 Share Posted March 20, 2007 Very cool, I've seen other examples of this before, mainly:Business Daysas the link says, most people know that as Business Days. Yours is still cool, and up-to-date (not sure if the one I posted works with the newest AutoIt, pretty sure yours will however).Note: Haven't tested either one as of yet (still at work), but the logic and code seems right. Link to comment Share on other sites More sharing options...
J_Y_C Posted March 21, 2007 Author Share Posted March 21, 2007 Yeah, I don't know why excel calls it "network days", and I didn't know if that was just a term I was ignorant to. Thanks tho. Link to comment Share on other sites More sharing options...
freanir Posted March 21, 2007 Share Posted March 21, 2007 Yeah, I don't know why excel calls it "network days", and I didn't know if that was just a term I was ignorant to.The function is called NETWORKDAYS(), which means net work days (The space between net and work is deliberate). freanir Link to comment Share on other sites More sharing options...
J_Y_C Posted March 21, 2007 Author Share Posted March 21, 2007 LMAO!! Thanks freanir, I astound myself on just how dense I can be! That makes perfect sense.. LOL Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now