<p>I have a weird date rounding problem that hopefully someone can solve.  My client uses a work week that runs from Monday through Sunday.  Sunday's date is considered the end of the week, and is used to identify all records entered in a particular week (so anything entered last week would have a WEEKDATE value of '10/26/2008', which is Sunday's date).</p>

<p>One little twist is that users enter records for the previous week up until 11 AM on the Monday of the current week.</p>

<p>So I need a function that starts with DateTime.Now and returns the week-ending date (no time part) according to the rules above.  Thanks for your help.  I have a solution that works, but I'm too embarassed to post it.</p>

<p>Oh, and I can't use LINQ.</p>

```
```
public DateTime WeekNum(DateTime now)
{
    DateTime NewNow = now.AddHours(-11).AddDays(6);

    return (NewNow.AddDays(- (int) NewNow.DayOfWeek).Date);
}

public void Code(params string[] args)
{

    Console.WriteLine(WeekNum(DateTime.Now));   
    Console.WriteLine(WeekNum(new DateTime(2008,10,27, 10, 00, 00)));
    Console.WriteLine(WeekNum(new DateTime(2008,10,27, 12, 00, 00)));
    Console.WriteLine(WeekNum(new DateTime(2008,10,28)));
    Console.WriteLine(WeekNum(new DateTime(2008,10,25)));

}
```
```
You may hard-code DateTime.Now instead of passing a DateTime object.  It just made testing easier this way.