convert to DateTime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Lindroos

    #1

    convert to DateTime

    how to convert this???


    string strDate = "19701105";
    DateTime myDate = System.Convert. ToDateTime(strD ate);

    ideas anyone

    /thomas lindroos
  • Jon Skeet [C# MVP]

    #2
    Re: convert to DateTime

    Thomas Lindroos <thomas.lindroo s@prosona.com> wrote:[color=blue]
    > how to convert this???
    > string strDate = "19701105";
    > DateTime myDate = System.Convert. ToDateTime(strD ate);[/color]

    Hvae a look at DateTime.Parse and DateTime.ParseE xact, where you can
    specify your own format.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • James Black

      #3
      Re: convert to DateTime

      Thomas Lindroos wrote:[color=blue]
      > string strDate = "19701105";
      > DateTime myDate = System.Convert. ToDateTime(strD ate);[/color]
      If you know the format is set, then just take a substring of the
      first 4 characters, turn it into an int, and set DateTime by using the
      year, month and day.

      Comment

      Working...