I have a form that takes an item from my database of “smalltime” type and I would like to re add this to another database as “smalldatetime” However the problem i ran into is that is reading my item a string. I am not sure what approach to take to convert this but here is what i have so far:
var checkOutDate = Convert.ToDateTime(ddlCheckOutDate.Text);
sl.ReqCheckOutDate = checkOutDate;
Can anyone help me over this hurdle?
The issue you are reporting is due to Culture difference. You are using US formatted date and the current culture is set to UK or similar so it thinks you are using Day/Month/Year and which makes 12/14/2013 is Day=12 Month=14 Year=2013 and therefore invalid.
Using DateTime.ParseExact will allow you to control the exact conversion of your date: