Formatting a String

  • Thread starter Thread starter Roshawn Dawson
  • Start date Start date
R

Roshawn Dawson

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
 
Roshawn said:
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")
 
Thanks guys and gals for your responses.

You've helped me a lot!!!

Thanks again,
Roshawn
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top