Parse String date to specific format

CoderT

This is a String date:

dob = reader.GetValue(7).ToString();` return like "12/2/2012"

But I want to convert (before passing it) to this format "2012212", I have tried

string newDate = dob.ToString("yyyMMdd")

But I got the following error:

The best overloaded method match for 'string.ToString(System.IFormatProvider)has some invalid arguments

any idea ?

sowjanya attaluri

Not Exact way of getting output but it will work.

   string dob = "12/2/2012";
   string[] d1 = dob.Split('/');
   string s = d1[2] + d1[1] + d1[0];

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related