String.Format with Dates

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);
 
B

BenoitM

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"));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top