MadBoy Posted June 11, 2008 Posted June 11, 2008 Hello, I've to develop Timesheet along with Holiday support in Sharepoint. While i know this isn't support section for Sharepoint what i need is realy an advice how to aproach the problem of weekends (code wise) and special holidays when emplyee gets free day anyway. I've user who has 20-26 days of holiday days to pickup. When he does that he chooses the date when he goes to holiday and when he comes back. Now the problem I have with weekends, and special days. If i choose starting date 2008-06-11 and the back date 2008-06-18 Sharepoint shows 7 days when it should be 5. Is there an easy algo to implement this kind of problem. With regards, MadBoy My little company: Evotec (PL version: Evotec)
sandin Posted June 11, 2008 Posted June 11, 2008 (edited) maybie try with this: expandcollapse popup#include <Date.au3> $holiday = _Calculate_Holiday("06/11/2008", "06/18/2008");I used this date format cause you get this format when you press F5 in notepad ;p MsgBox(0, "Holiday days:", $holiday) ;=============================================================================== ; ; Description: Calculates working days between two dates ; Parameter(s): $date1 - Date when the holiday starts ; $date1 - Date when the holiday ends ; Requirement(s): #include <Date.au3> ; Return Value(s): On Success: number of days ; ;=============================================================================== func _Calculate_Holiday($date1, $date2) Local $date_string_date1 = StringSplit($date1, "/") Local $date_string_date2 = StringSplit($date2, "/") Local $days1 = 0 Local $days2 = 0 Local $year1 = $date_string_date1[3] Local $month1 = $date_string_date1[1] Local $day1 = $date_string_date1[2] Local $year2 = $date_string_date2[3] Local $month2 = $date_string_date2[1] Local $day2 = $date_string_date2[2] for $i = 1 to $month1 Local $iDays = _DateDaysInMonth( $year1,$i ) $days1 += $iDays Next $days1 += $day1 for $j = 1 to $month2 Local $jDays = _DateDaysInMonth( $year2,$j ) $days2 += $jDays Next $days2 += $day2 Local $total_days = $days2-$days1 Local $iWeekday1 = _DateToDayOfWeek ($year1, $month1, $day1) Local $count_date = 0 for $n = 1 to $total_days ;not sure if the day when holiday start should be included, if it should then start this line with $n = 0 to $total_days Local $nWeekDay = _DateToDayOfWeek ($year1, $month1, $day1+$n) Local $aWeekDay = _DateDayOfWeek($nWeekDay) if $aWeekDay <> "Saturday" and $aWeekDay <> "Sunday" then $count_date += 1 Next Return $count_date EndFunc ;==> _Calculate_Holiday() Edited June 11, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
MadBoy Posted June 11, 2008 Author Posted June 11, 2008 That's very good. If only Sharepoint would be like AutoIt ;-) Well i'll go thru the udf's from data.au3 and see if i can convert your code + udf to excel alike counting. My little company: Evotec (PL version: Evotec)
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