Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check date if weekday or holiday.

Status
Not open for further replies.

magmo

Programmer
May 26, 2004
291
SE
Hi


I wonder if it possible to check if a date is a weekday or a holiday in vb.net.


Regards
 
check if it's a holiday is difficult at best (Easter and all the related holiday can easily(?) be calculated.

this is it for easter, sorry code was written for my vb.net exam and therefor most variabels are dutch.

Code:
Private Function Bereken_Pasen() As Feestdag
            If Jaar > 1582 Then
                Dim a, eeuw, c, d, f, g, h, i, j, k, l, m, n, p As Double
                Dim paasmaand, pasen As Integer
                eeuw = Fix(intJaar / 100)
                c = intJaar \ 100
                n = intJaar - 19 * (intJaar \ 19)
                k = Convert.ToInt32((c - 17)) \ 25
                i = c - Convert.ToInt32(c) \ 4 - Convert.ToInt32((c - k)) \ 3 + 19 * n + 15
                i = i - 30 * (Convert.ToInt32(i) \ 30)
                i = i - (Convert.ToInt32(i) \ 28) * (1 - (Convert.ToInt32(i) \ 28) * (29 \ Convert.ToInt32((i + 1))) * (Convert.ToInt32((21 - n)) \ 11))
                j = intJaar + intJaar \ 4 + i + 2 - c + Convert.ToInt32(c) \ 4
                j = j - 7 * (Convert.ToInt32(j) \ 7)
                l = i - j
                paasmaand = 3 + Convert.ToInt32((l + 40)) \ 44
                pasen = Convert.ToInt32(l + 28 - 31 * (Convert.ToInt32(m) \ 4))
                If paasmaand = 4 Then
                    pasen -= 31
                End If
                Return New Feestdag("Pasen", Convert.ToDateTime(pasen & "/" & paasmaand & "/" & intJaar))
            Else
                Return Nothing
            End If
        End Function

determening if a day is a weekday is even simpler

Code:
now.DayOfWeek

and look if it's 1 thru 5. 0 will most likely be a sunday and saterday a 6.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top