String.Format with Dates

  • Thread starter Thread starter john sutor
  • Start date Start date
J

john sutor

I tries using this format to return "08/19/1958", but I got back just what I
input which was 08/19/58. Any hints
string st4=String.Format("{0:MM/dd/yyyy}", 08/19/58);
 
do you pass the date to format like this : 08/19/58 ?? perhaps you forgot
the quotes : "08/19/58" ? anyway it won't work since it will be seen as
string, you need a DateTime...
this should work:

string st4 = String.Format("{0:MM/dd/yyyy}",
Convert.ToDateTime("08/19/58"));
 
Back
Top