Formatting a String

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roshawn Dawson

    #1

    Formatting a String

    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
  • Anand[MVP]

    #2
    RE: Formatting a String

    You can use String.Format

    --
    Rgds,
    Anand
    VB.NET MVP



    "Roshawn Dawson" wrote:
    [color=blue]
    > 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
    >[/color]

    Comment

    • Larry Lard

      #3
      Re: Formatting a String



      Roshawn Dawson wrote:[color=blue]
      > 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[/color]

      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.ParseE xact(Input, "yyyy-MM-dd",
      Nothing)
      Dim Output As String = MyDate.ToString ("MMMM d, yyyy")

      --
      Larry Lard
      Replies to group please

      Comment

      • Roshawn Dawson

        #4
        Re: Formatting a String

        Thanks guys and gals for your responses.

        You've helped me a lot!!!

        Thanks again,
        Roshawn

        Comment

        • Roshawn Dawson

          #5
          Re: Formatting a String

          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

          Comment

          Working...