unable to update datetimepicker date values sqlserver database.
Posted on 2009-02-11
I tried to update one table with :
update StatusOfFittings set FittingCompletedDate = '05-02-2009 PM 03:13:50' where FittingName = 'WBSTDWTzxcvbn'
Here FittingCompletedDate is the datetime Datatype.
I am using DatetimePicker control in C#-winforms front end.
ditrectky i took the date like: FittingCompletedDate = 'datetimepicker.value.ToString()'
I got exception: "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
One of Expert given this comment before:
pratima_mcs:try something like this
FittingCompletedDate = 'datetimepicker.value.ToString("yyyy-MM-dd hh:mm:ss")
I changed like this, but I able to update only time, changes of am to pm .
Means..as per time: '05-02-2009 PM 03:13:50' but it updates '05-02-2009 AM 03:13:50' like this.
Plz help on this. I want to update exact timing into the sql database.