format date string

Posted on 2004-10-21
Last Modified: 2008-02-01
I have a string  01012004  which is in format ddmmyyyy

i want to format it so it can be converted to a valide date

I'm trying but doesn't work??

strInDate = string.Format(strInDate,"{0:##/##/####}");  
strOutDate = DateTime.Parse(strInDate);

Question by:rourkas1

    Accepted Solution

    DateTime dtInput = DateTime.ParseExact(sDate, "ddMMyyyy", System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat);
    LVL 3

    Expert Comment

    outDate = inDate.Substring(0, 2) + "/" + inDate.Substring(2, 2) + "/" + inDate.Substring(4);


    outDate = DateTime.ParseExact(date, "ddMMyyyy",

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Title # Comments Views Activity
    Inheritance in C# 3 56
    inaccessible due to protection level? 12 51
    Upgrading model from database 2 28
    Add row in datatable 18 33
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Want to pick and choose which updates you receive? Feel free to check out this quick video on how to manage your email notifications.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now