lolipop Posted February 12, 2014 Share Posted February 12, 2014 Anyone have any idea how I can achieve getting the number of days between two dates excluding weekend(Sat & Sun). For example, if I input 1 Jan 2014 til 8 Jan 2014. I will get the number of days as 6 instead of 8? Any advise is appreciated. TIA Link to comment Share on other sites More sharing options...
Solution GaRydelaMer Posted February 12, 2014 Solution Share Posted February 12, 2014 (edited) Hi i've made this function: #include <Date.au3> ConsoleWrite(_JoursOuvres("2014/01/01", "2014/01/08") & @LF) ;; Return 6 Func _JoursOuvres($Start_Date, $End_Date) Local $DT = $Start_Date, $iCount = 0, $Y, $M, $D While $DT <= $End_Date $Y = StringRegExpReplace($DT, "(\d+)/.*", "$1") $M = StringRegExpReplace($DT, ".*/(\d+)/.*", "$1") $D = StringRegExpReplace($DT, ".*/(\d+)", "$1") If _DateToDayOfWeek($Y, $M, $D) <> 1 And _DateToDayOfWeek($Y, $M, $D) <> 7 Then $iCount += 1 EndIf $DT = _DateAdd("D", 1, $DT) WEnd Return $iCount EndFunc Edit spelling Edited February 12, 2014 by GaRydelaMer Link to comment Share on other sites More sharing options...
lolipop Posted February 12, 2014 Author Share Posted February 12, 2014 (edited) Sorry. My bad for misunderstanding the code. It works perfectly. Thank you very much. PS: You might want to edit the code. The function(JoursOuvre) is missing a "s" which is causing the code to fail. Edited February 12, 2014 by lolipop Link to comment Share on other sites More sharing options...
GaRydelaMer Posted February 12, 2014 Share Posted February 12, 2014 Sorry for'S' a bad copy/paste 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