0

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

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

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!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.