Hello,
Try following code
Made one function as follows
Public Function NettoWorkdays(ByVal dtmStart As Date, ByVal dtmEnd As Date) As Integer
'This function calculates the number of working days (monday to friday) between 2 dates,
'including the first and the last day
Dim intDays As Integer
Dim intSubtract As Integer
' if end is smaller then start return -1
If dtmEnd < dtmStart Then
NettoWorkdays = -1
Else
' Get the start and end dates to be weekdays.
While Weekday(dtmStart) = vbSaturday Or Weekday(dtmStart) = vbSunday
dtmStart = dtmStart.AddDays(1)
End While
While Weekday(dtmEnd) = vbSaturday Or Weekday(dtmEnd) = vbSunday
dtmEnd = dtmEnd.AddDays(-1)
End While
If dtmStart > dtmEnd Then
' Sorry, no Workdays to be had. Just return 0.
NettoWorkdays = 0
Else
intDays = DateDiff(DateInterval.Day, dtmStart, dtmEnd) + 1
' Subtract off weekend days. Do this by figuring out how
' many calendar weeks there are between the dates, and
' multiplying the difference by two (because there are two
' weekend days for each week). That is, if the difference
' is 0, the two days are in the same week. If the
' difference is 1, then we have two weekend days.
intSubtract = (DateDiff("ww", dtmStart, dtmEnd) * 2)
NettoWorkdays = intDays - intSubtract
End If
End If
End Function
Call above function as follows
Dim LeaveDay As Double
LeaveDay = NettoWorkdays(Convert.ToDateTime("2011-12-03"), Convert.ToDateTime("2011-12-12"))
Dim LeaveType As String
LeaveType = "Half" ' Set Your RadioButton List Value Here If LeaveType 'Half' then LeaveDay/2 is Total Leave other wise LeaveDay is Total Leave
If LeaveType = "Half" Then
LeaveDay = LeaveDay / 2
End If
Check it and let me know your feedback
Hope this is helpful !
Thanks