Ok now this is just weird. i used this line of code everyday and worked fine and suddenly this morning just threw an error in my face
DateTime dt = Convert.ToDateTime(cpCreateDate.SelectedDate.ToString("dd/MM/yyyy"));<br />
ok the cpCreateDate control is a datetime picker and the value is for example
"09/01/2007 12:00:00 AM"
all i want to do is format it to only the date meaning removing the time to save this to a sql database.
the problem is that as soon as it converts the string back to a datetime value it keeps on adding the time back again and i get this error when trying to write the value to the database:
"The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.
The statement has been terminated."
the column in the sql database table is a smalldatetime data type and changing that to normal datetime doesnt resolve this.