I read a string using this format with a data reader. How can I read in a date using similar format?
while (MyReader.Read()) { TextBox1.Text = (string)MyReader["Note"]; }
Try as given below:
while (MyReader.Read()) { TextBox1.Text = Convert.ToDateTime(MyReader["DateField"]).ToString("dd/MM/yyyy"); }
in ToString() method you can change data format as per your requirement.
ToString()
1.4m articles
1.4m replys
5 comments
57.0k users