471,627 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

string formatting...what am I doing wrong?

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?
Dec 9 '05 #1
2 1170
TJ wrote:
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

Dec 9 '05 #2
TJ
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!
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
TJ wrote:
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

Dec 9 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by hagai26 | last post: by
7 posts views Thread by ilona | last post: by
5 posts views Thread by Chris H | last post: by
6 posts views Thread by Scewbedew | last post: by
11 posts views Thread by Dustan | last post: by
14 posts views Thread by Scott M. | last post: by
9 posts views Thread by =?Utf-8?B?TmVpbEdvdHQ=?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.