DateTime?.ToString(format)

.net, c#, datetime, datetime-format, nullable

Solution

if (t1.HasValue)
    string st1 = t1.Value.ToString(format);

Problem

Possible Duplicate: How can I format a nullable DateTime with ToString()? got issue parsing DateTime? to specific format. Like: ``` DateTime t1 = ...; string st1 = t1.ToString(format); //<-- works DateTime? t1 = ...; string st1 = t1.ToString(format); //Dont work. ``` Theres no overload method for DateTime?

Original source

Related problems