Introduction
For programmers, specially for whom who works on calendar based project, its always necessary to work with different factors of date. To find out total number of weeks in months is one of important task in it.
After plenty of search, i don't get expected result to find total number of weeks in a month. Then i tried my own idea and develop the code given below. This was working fine with me. If required, check it and analysis it.
Using the code
Find the code given below. I have tested this code and implemented in my applications. With some syntax changes, same will be implemented using C#.net
Public Shared Function GetTotalWeeks(month As Integer) As Integer
Dim today As Date = DateTime.Now
Dim daysinmonth As Integer = DateTime.DaysInMonth(today.Year, month)
Dim firstOfMonth As DateTime = New DateTime(today.Year, month, 1)
Dim firstDayOfMonth As Integer = (firstOfMonth.DayOfWeek)
Dim weeksInMonth As Integer = Math.Round((firstDayOfMonth + daysinmonth) / 7.0)
Return (weeksInMonth)
End Function
I am working as an application developer for last ten years. I am mostly develop applications in ASP.NET. But, also I work in Android and Java.
Currently I am working in a company as a Sr. Application Developer. I have a team of developers and I am playing a role of team leader.
Also, I assist academic projects based on IEEE papers for ME for last ten years.
I believed on a logic development and not on a programming language. I think that, if some one was strong in logic development then he/she can easily develop an application in any programming language.
I am working on tools/domains like, image processing, networking, cloud computing, etc. Out of them, cloud computing is my favorite working domain.