Hi Folks,

How we can check the current date is in between the first week of the current month and last week of the last month

Use System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear() method.

Hi Folks,

How we can check the current date is in between the first week of the current month and last week of the last month

hi jithusdani

You can do like this
for your first condition

Public Function IsCurrentDateInFirstWeek() As Boolean

        Dim dt As Date = Date.Today
        Dim FirstWeekStartDate, FirstWeekEndDate As String

        FirstWeekStartDate = DateSerial(dt.Year, dt.Month, 1)
        FirstWeekEndDate = DateAdd(DateInterval.Day, 7, CDate(FirstWeekStartDate))

        If Date.Today.ToString("MM/dd/yyyy") >= FirstWeekStartDate And _
                     Date.Today.ToString("MM/dd/yyyy") <= FirstWeekEndDate Then
            Return True
        End If
        Return False
        
    End Function

Make sure you compare date according to you local date time format


Mark as solved if it helps you!!!

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.