By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,066 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,066 IT Pros & Developers. It's quick & easy.

Formatting a String

P: n/a
Hi,

I have a string that looks like this:

2005-06-01

I'd like to make this string look like this:

June 1, 2005

Any ideas, oh great ones?!

Thanks,
Roshawn
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You can use String.Format

--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com
"Roshawn Dawson" wrote:
Hi,

I have a string that looks like this:

2005-06-01

I'd like to make this string look like this:

June 1, 2005

Any ideas, oh great ones?!

Thanks,
Roshawn

Nov 21 '05 #2

P: n/a


Roshawn Dawson wrote:
Hi,

I have a string that looks like this:

2005-06-01

I'd like to make this string look like this:

June 1, 2005


First make a Date(Time) of it using ParseExact, then use ToString with
a format specifier:

Dim Input As String = "2005-06-01"
Dim MyDate As Date = DateTime.ParseExact(Input, "yyyy-MM-dd",
Nothing)
Dim Output As String = MyDate.ToString("MMMM d, yyyy")

--
Larry Lard
Replies to group please

Nov 21 '05 #3

P: n/a
Thanks guys and gals for your responses.

You've helped me a lot!!!

Thanks again,
Roshawn
Nov 21 '05 #4

P: n/a
It appears that I've run into a new problem. I'm now receiving strings
like this:

2005-06

Ok. I won't always know how the string is formatted when I receive it.
So how can I get the string to say June 2005 if I'm given either of
these strings:

2005-06-01

OR

2005-06

Thanks,
Roshawn
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.