How can I convert a date time string to int format yyyyMMdd

BusinessDate = 2012-09-27 00:00:00.000

Would like to convert to 20120927
Who is Participating?
Fernando SotoConnect With a Mentor RetiredCommented:
Hi countrymeister;

This will do what you need.

string dtStr = "2012-09-27 00:00:00.000";

string date = DateTime.Parse(dtStr).ToString("yyyyMMdd");

Open in new window

AndyAinscowFreelance programmer / ConsultantCommented:
DateTime dte = new DateTime(2012,09,27,0,0,0);
            String s = dte.ToString("yyyyMMdd");
//s is 20120927
AndyAinscowFreelance programmer / ConsultantCommented:
Aha - the question really was how to convert a string into a datetime.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.