3
Answers

How to convert m/d/yyyy string to mm/dd/yyyy to bind excel ?

Sujeet Raman

Sujeet Raman

3y
607
1

Hi,

I have a string coming from excel as "8/3/1989" (m/d/yyyy) in below code.I need to convert it in to 08/03/1989 .In excel coloumn the format is text.I alwas getting error after every conversion like input string is not in correct format in. below code I am using

string effdate= xlWorksheet.Cells[i, 8].Value.ToString();
DateTime dt = DateTime.Parse(effdate);
xlWorksheet.Cells[i, 8] = dt.ToString();
xlWorksheet.Cells[i, 8].NumberFormat = "MM/DD/YYYY";
Answers (3)