Dateformat with nullable variable
<p>I have this code:</p>

<pre><code> startWeekDate = startWeekDate == null ? DateTimeHelpers.calcMondayDate(DateTime.Now) : DateTimeHelpers.calcMondayDate(startWeekDate.Value);
 DateTime endWeekDate = startWeekDate.Value.AddDays(6);
</code></pre>

<p>startWeekDate is a parameter that is nullable. This works good, but I want to format it with: String.Format("{d:0}", .... ) but when I slap that around it I get error.</p>

<p>Cannot implicitly convert type 'string' to 'System.DateTime?</p>

<p>How shall I fix this problem?</p>

<p>/M</p>

<p>EDIT:</p>

<p>I'm trying to add this to the function instead, since it should always return dateformat without clock, but I get same error there with this code:</p>

<pre><code>    public static DateTime calcMondayDate(DateTime input)
    {
        int delta = DayOfWeek.Monday - input.DayOfWeek;
        DateTime monday = String.Format("{d:0}", input.AddDays(delta));

        return monday;
    }
</code></pre>

<p>Cannot implicitly convert type 'string' to 'System.DateTime'</p>

<p>hmm, but input is DateTime, why does it complain about it being string?</p>
