Monday, April 21, 2014

Formatting DateTime type to display just the date in C#

                     Formatting DateTime type to display just the date.

Requirement: To display just the date using the object of DateTime type.

Solution: Declare a string type variable to hold the date.

                   public String NextDate { get; set; }

             
        NextDate = string.Format("{0:MM/dd/yyyy}", DateTimeVariableToBeFormatted)


It will let you display the DateTime format of “4/30/2014 12:00:00 AM” type to

Date format “04/30/2014”

No comments:

Post a Comment