0

Please help me with the issue . I have tried lot many solution and they are not working .

rd["DOB"].ToString() = "9/19/1946"; DateTime dt1 = DateTime.ParseExact(rd["DOB"].ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); 

3 Answers 3

3

You should use "M/d/yyyy" as the format string.

MM/dd/yyyy would match 09/19/1946, but not 9/19/1946

Sign up to request clarification or add additional context in comments.

Comments

2

You can refer below URL for more grasp on date time format http://msdn.microsoft.com/en-us/library/az4se3k1.aspx

Comments

1

Have you tried using the Convert class?

Convert.ToDateTime(rd["DOB"]); 

If you are using System.Data.DataRow and the column "DOB" is of type SqlDateTime then that should work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.