Identify Second and Fourth Saturdays of Each Month, and All Sundays, for a Whole Year

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Narender Sagar
    New Member
    • Jul 2011
    • 189

    Identify Second and Fourth Saturdays of Each Month, and All Sundays, for a Whole Year

    Dear All,
    I want to create a database, in which I have to maintain Production Plan for the year. The condition is that every 2nd and 4th Saturday & all the Sundays in a month will be Holiday. There can be more holidays in a year for which there will not or should not be any production plan.
    Can you please guide me, what should be my table structure?
    I have created following tables: 1) tblDays 2)tblMonths 3)tblYears 4)tblHolidays. And by using functions
    Code:
    dteDate: DateSerial(tblYears.Year,tblMonths.Month,tblDays.Day)
    ) in the query, I am able to generate Dates for the entire year. Now I want to indicate non working days wrt Saturdays, Sundays and other Holidays, in other query, for which I am not able to figure out for alternate Saturdays.
    thanks
    regards
    Narender Sagar
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    I would produce a Public function procedure which is passed a date and returns a boolean result to indicate whether or not the date matches the specified criteria.

    Separately, I would maintain a table of holiday dates which would need to be maintained.

    A date would then be considered a holiday if either :
    1. It matched a date in the holiday table.
    2. The function returned the value True.


    The function would be similar to :
    Code:
    Public Function IsHol(datThis As Date) As Boolean
        IsHol = True
        If Weekday(datThis, vbSunday) = 1 Then Exit Function
        If Weekday(datThis, vbSaturday) = 1 Then
            If Day(datThis) > 7 And Day(datThis) < 15 Then Exit Function
            If Day(datThis) > 21 And Day(datThis) < 29 Then Exit Function
        End If
        IsHol = False
    End Function

    Comment

    • Narender Sagar
      New Member
      • Jul 2011
      • 189

      #3
      Thanks a lot Neopa..
      This is what I needed.
      It served the purpose.
      thanks once again.
      kind regards,
      Narender Sagar

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        You're welcome Narender. It always helps when one can understand what the question is saying :-)

        Comment

        Working...