TheDProgrammer TheDProgrammer - 1 year ago 64 Question

How to know today is which Monday, Tuesday, Wednesday, etc. (in number) of this month?

My question is:

Today's Day and Date are: Wednesday, June 8, 2016. I want to know today is which Wednesday of the current Month (like 2nd Wednesday). How I can do this using VB .NET?

I have tried the solution provided in:

How do I get first, second or last Tuesday (or any day of the week) of a given month

This solution accepts "Name of the Day" and "Week Number of the Day" and provides the output as the Date. I want the results differently as I should input the Date and the result should be the "Day Number of the Day" and "Current Day Name", like "Today is 2nd Wednesday".

Any help will be highly appreciated.

Answer Source

Try this:

Module Module1

    Sub Main()
        Dim now As DateTime = #6/8/2016#
        Dim dayCount As Integer = 0
        Dim modResult As Integer = If((now.Day Mod 7) > 0, 1, 0)
        dayCount = (now.Day \ 7) + modResult


    End Sub

End Module
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download