Friday, 17 May 2013

how to find records for last and current week in c#?

Hi all  in this post i'll show how to find records for last and current weeks in c#, if any one want this for smaller DB you can done this in code side, you can fine the dates for last and current weeks records


     DateTime startOfWeek = DateTime.Today;
     int delta = DayOfWeek.Monday - startOfWeek.DayOfWeek;
     startOfWeek = startOfWeek.AddDays(delta);
     DateTime endOfWeek = startOfWeek.AddDays(6);
     DateTime LastWeekStart = startOfWeek.AddDays(-7);

then with above values you can find out the records easily for small DB its better to done in this way.

No comments:

Post a Comment