Hi..
anyone outthere have sample coding leave application. This application will calculate how many days u take leave not including public holidays.
Please help me?

Dani AI

Generated

A compact, practical plan that fits the scenario raised by and the state/region concerns mentioned by : make public holidays and weekend-days configurable, store holidays as date-only records (with an optional observed date and region), and count inclusive calendar days while excluding configured weekends and holiday dates.

Store holidays in a simple table (HolidayDate, ObservedDate, Description, Region) and load only the relevant region/year into memory. Decide whether the end date is inclusive (most leave systems count both start and end when you take whole days). Normalize everything to Date-only before comparisons to avoid time-part bugs.

Function CountLeaveDays(startDate As DateTime, endDate As DateTime, holidays As IEnumerable(Of DateTime), weekendDays As IEnumerable(Of DayOfWeek)) As Integer
    If endDate < startDate Then Return 0
    Dim holidayList As New List(Of DateTime)
    For Each h As DateTime In holidays
        holidayList.Add(h.Date)
    Next
    Dim weekendList As New List(Of DayOfWeek)(weekendDays)
    Dim count As Integer = 0
    Dim d As DateTime = startDate.Date
    While d <= endDate.Date
        If Not weekendList.Contains(d.DayOfWeek) AndAlso Not holidayList.Contains(d.Date) Then
            count += 1
        End If
        d = d.AddDays(1)
    End While
    Return count
End Function

' Example usage:
' Dim holidays = LoadHolidays(region, year)    ' returns IEnumerable(Of DateTime)
' Dim weekend = New List(Of DayOfWeek) From { DayOfWeek.Friday, DayOfWeek.Saturday }
' Dim daysTaken = CountLeaveDays(startDate, endDate, holidays, weekend)

Notes and common pitfalls: include observed dates when a holiday falls on a weekend; keep the holiday list per-region to honor 's point; for very large ranges you can optimize by counting whole weeks, but a simple loop is fine for typical leave spans. If the system must support half-days or hourly leave, count fractions (0.5) or work in hours rather than days. Validate inputs (start ≤ end) and always compare .Date to avoid timezone/time-part errors.

Some public holidays vary from state to state and some public holidays are celebrated at different times. For example WV had the Monday off following New Year's and GA had the Friday off before New Years. Now are the weekends work days or are they non work days. Also, what day of the week does your work week /pay period / leave period start and end?

Chester

Hi..
Tq reply my message..
This system only capture public holiday..Friday and saturday for every week is public holiday.
working day start on Sunday till Thursday. 21st Apr is public holiday.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.