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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top