how to convert CYYMMDD date format to asp.net dateformat YYYY-MM-DD in asp.net using

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sandhya123
    New Member
    • Dec 2015
    • 2

    how to convert CYYMMDD date format to asp.net dateformat YYYY-MM-DD in asp.net using

    I am getting date from DB2 in CYYMMDD format 1234567,i have to convert this into normal asp.net date using C#.
  • sandhya123
    New Member
    • Dec 2015
    • 2

    #2
    Originally posted by Elisa Gracedd
    Try this.....

    The ToString method on the DateTime struct can take a format parameter:

    var dateAsString = DateTime.Now.To String("yyyy-MM-dd");
    // dateAsString = "2015-12-17"

    Read also


    ASP.NET Tutorials
    Hi Thanks for the reply. But Here you are using DateTime.Now.so it is working fine but my case i am getting the value from DB2 in the format CYYMMDD.

    i.e for example 0170312 then first i have to convert this string value to Date.

    this string contains 7 digits and converting itself failed.

    Comment

    Working...