How Do I convert a datetime from mm/dd/yyyy to dd MMM yyyy? DateTime.ParseExact or DateTime.TryParseExact does not require a parameter that tells it what format I want it in. So how does it know that I want it to return the passed in date to dd MMM yyyy format?
DateTime result;
var dateTime = DateTime.TryParseExact("03/21/2013", "mm/dd/yyyy",CultureInfo.InvariantCulture,DateTimeStyles.None, out result);
dateTimevariable there is a boolean - theTryParseExactmethod returns a boolean indicating whether or not the parsing was successful. Assuming it's successful, the value will be stored in yourresultvariable. - Joe Enos"MM/dd/yyyy", or more correctly"MM\\/dd\\/yyyy"(the backslash escapes out the forward slash so the system knows that it's a true forward-slash and not a special character represented by a forward-slash - it's complicated, but definitely use the backslash). (Oh, and the two backslashes are because it's a C# escape character, so it's really only one). - Joe Enos