MVC View nullable Date field formatting

I am trying to display the following in a view but is giving a problem:

    <td>
     @item.CreatedByDt.ToString("MM/dd/yyyy") 
    </td>  

Any idea on how to handle a nullable Date field in a view. I am using Razor by the way.

I am getting the following error:

No overload for method 'ToString' takes 1 arguments

Answers


If you don't know if it will be null or not...

@string.Format("{0:MM/dd/yyyy}", item.CreatedByDt)

Need Your Help

Best practice integrating Spock with Jenkins, Sonar

java continuous-integration sonarqube build-automation spock

We decided to give Spock a try as a testing framework for our java based EE application. Currently we have a CI infrastructure deployed based on jenkins + maven + jacoco.

GetColumName(i) returns “” when using UNION (Jaybird)

java union firebird jaybird

I'm a little bit confused with my new SQL query using a union.