I have a String that looks like
4/2/2012 12:00 AM
12/30/1899 10:00 AM
I want to format the strings so the first date/time stamp looks like
4/2/2012
The second should look like
10:00 AM
SHould I use the whitespace as a means to split the string?
For complete string -->
string s= DateTime.Parse("4/2/2012 12:00 AM").ToString("d/M/yyyy hh:mm tt");
For separated strings -->
string date=DateTime.Parse("4/2/2012 12:00 AM").ToString("d/M/yyyy");
string time = DateTime.Parse("4/2/2012 12:00 AM").ToString("hh:mm tt");
DateTime.TryParse also - nice if the input strings are not guaranteed to be properly formatted. Returns true if the parse was successful.Have a look here
Just add .Tostring("") and between the "" you add the pattern, as shown at the site