Detecting that date is on the same week or last week.

  • Thread starter Thread starter Hadi
  • Start date Start date
H

Hadi

Hello,

I have to DateTime structure, how do I calculate if date A is on the same
week with date B or last week of date B?

Thanks,

Hadi
 
if ( a. AddDays( 7- a.DayOfWeek ).Date.Equals(b.AddDays(
7-b.DayOfWeek ).Date) )

{

// their int the same week

}

else if ( a. AddDays( 7-
a.DayOfWeek ).Date.Equals(b.AddDays( -b.DayOfWeek ).Date) ){

// a is in the last week of b
}



Hope this help.
 
Back
Top