Link to home
Start Free TrialLog in
Avatar of solraccheffy
solraccheffy

asked on

format string to remove day of week

I am using VS.NET 2003 and need to display date but dont want the day of the week...so my string is currently....
Wednesday, April. 23, 2008
I created a case statement to check and truncate the month from April to Apr.
now i want to remove the day of the week, can I do this easier than doing a case statement and a replace, for each day of the week, looking for something with less code, perhaps an array type of idea...but not sure on how to go about that.

Wednesday, Apr. 23, 2008
Avatar of kaufmed
kaufmed
Flag of United States of America image

So something like below doesn't work for you?
DateTime d = new DateTime(2009, 5, 1);
 
d.ToString("MMM dd, yyyy")

Open in new window

Avatar of solraccheffy
solraccheffy

ASKER

getting this error...
Argument '1': cannot convert from 'string' to 'long'
The best overloaded method match for 'System.DateTime.DateTime(long)' has some invalid arguments

The string I am passing is "Wednesday, April 23, 2008" does not work in your example.

DateTime newDate = new DateTime(FormattedDate);
return newDate.ToString("MMM dd, yyyy");
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Snippet to ponder


String date = "Wednesday, Apr. 23, 2008";
 
  String parts = date.Split (",");
 
  date = parts[1]+","+parts[2];

Open in new window