How can I do this?
I know it's probably extremely simple, but everything I've tried leaves the date as: 1/5/2005 instead of 01/05/2005.
Thanks,
Mark
DateTime.Now.ToString("MM/dd/yyyy")
The field I'm working with is astring type not a datetime.
string dueDate;
The "dueDate" field is populated from the database with:
1/5/2005
How do you format a "string" that contains a date with a given format. Like I said, everything on the internet shows the DateTime.Now.ToString(...) that you've shown. My question is regarding a string that contains a date.
Thanks,
Mark
If your converting it to a string specifically to format it, you can avoid loosing the datetime features of that field by just using a Format([DateTime[), "MM/dd/yyyy")
string dateText = "1/5/2005";
DateTime dateTimeValue = System.DateTime.Parse(dateText);
string formattedValue = dateTimeValue.ToString("MM/dd/yyyy");
this.Response.Write("formattedValue: " + formattedValue + "<br>");
NC...
0 comments:
Post a Comment