string formatting...what am I doing wrong?

  • Thread starter Thread starter TJ
  • Start date Start date
T

TJ

Why doesn't this work?\

string _s = String.Format("{0:M/d/yyyy}","5/20/2005 12:00:00 AM);
Response.Write(_s);

It kicks back the full date and time...I just want the date to show and not
the time. What am I doing wrong?
 
TJ said:
Why doesn't this work?\

string _s = String.Format("{0:M/d/yyyy}","5/20/2005 12:00:00 AM);
Response.Write(_s);

It kicks back the full date and time...I just want the date to show and not
the time. What am I doing wrong?

You're not formatting a DateTime - you're formatting a *string*.

Parse the string into a DateTime, then format it.

Jon
 
Ah, was wondering why this worked in my aspx page in my databind results.
Using DataBinder.Eval adjusts it to DateTime for you. I'm moving to the
code behind and didn't cast first myself.

Thanks!
 
Back
Top