error-cannot convert from 'System.DateTime?' to 'string' C#
<p>Here LogInTime and LogOutTime are datetime datatype. How to convert string format code with respect to Datetime in c#?</p>

<p>LogOutTime and LogInTime both are datetime datatype.</p>

<pre><code>new
{             
    AccessDate = (DateTime.TryParse(x.LogOutTime, out parsed)) ? parsed.ToShortDateString() : "Unknown",
    AccessTimeFrame = (DateTime.TryParse(x.LogOutTime, out parsed)) ? parsed.ToShortTimeString() : "Unknown"
}
</code></pre>

<p>Now it occurred error. 
"cannot convert from 'System.DateTime?' to 'string'"</p>