Hi again

I thought I had this sorted until I realised the date I needed to convert was 91202 (YmmDD). Also, when specifying the format, I have no idea the relevance of the lower-case/capitalisation of the letters (YmD etc?)

Any help appreciated.

private static string ConvertDT(string date, string informat, string outformat)
        {
            DateTime convertedDate;

            if (!DateTime.TryParseExact(date, informat, new CultureInfo("en-GB"), DateTimeStyles.None, out convertedDate))
                throw new FormatException(string.Format("Unable to format date:{0}", date));

            return convertedDate.ToString(outformat);
        }

String convertedDate = ConvertDT(“91201” "yMMdd", "yy/MM/dd"); // 01 December 2009

I gave up and as below I decided to... cheat!. It works but I'd be interested in any proper ways to do this :-)
Thanks

string tempdate = date.PadLeft(6, '0');

IMO you cannot express a year with one digit. With 2 digits a computer might infer to put a 19 or 20 before it, depending on the situation.

Its amazing after the world almost ended for Y2K that people would use anything other than a 4 digit year!

The following year problem will happen at the end of the year which is still 7990 years from now.:S

There is also a Y2K38 bug too:
http://en.wikipedia.org/wiki/Year_2038_problem

This one is more credible of an issue than Y2K in my opinion because it *will* start representing dates wrong. I'm sure we will have everything upgraded by then though. No need to build a bunker :)

Yeah, forgot about Unix time.:|

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.