locked
how to selected date is this week or not? RRS feed

  • Question

  • how to selected date is this week or not?

    suppose this week  ne

    i will open next week only the particular Page...



    Monday, December 17, 2012 2:23 PM

Answers

  • You can calculate start/end week dates from the current date. Then compare whether selected date falls between start and end.

            Dim dateOfFirstDay As DateTime = DateTime.Now.AddDays(-DateTime.Now.DayOfWeek)
            Dim dateOflastDay As DateTime = DateTime.Now.AddDays(-DateTime.Now.DayOfWeek + 6)
            
            If selectedDate >= dateOfFirstDay And selectedDate <= dateOflastDay Then
                MessageBox.Show("Selected Date is in this week")
            End If


    A.m.a.L Hashim
    Microsoft Most Valuable Professional
    My Blog - Dot Net Goodies

    • Marked as answer by Madasamyponraj Monday, December 17, 2012 3:56 PM
    Monday, December 17, 2012 3:17 PM