CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    8

    [RESOLVED] how to convert a string to date format?

    Hi All,

    I have a string like this '20051022'(YYYYMMDD). I want to convert into '10/22/2005'(MM/DD/YYYY). Can anybody suggest on this?

    Thanks in advance

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: how to convert a string to date format?

    Code:
    string initial = "20051022";
    string final = initial.substring(4,2) + "/" + initial.substring(6,2) + "/" + initial.substring(0, 4);
    Learn more about string operations by reading this tutorial: http://www.techotopia.com/index.php/...ngs_in_C_Sharp
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    May 2012
    Posts
    8

    Re: how to convert a string to date format?

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured