Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

Insert DateTime with ("yyyy-MM-dd " + _tbStartTime.Text + ":" + _tbStartMinute.Text + ":ss";

trying to insert datettime into db from asp.net code behind with same date, but different time like -->

Convert.ToDateTime(dtSAC.Rows[0]["starttime"].ToString("yyyy-MM-dd" + _tbStartTimeHour.Text + ":" + _tbStartTimeMinute.Text + ":ss"))

but its giving error , 'No overload for method 'ToString' takes 1 arguments
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

why not take the starttime field, which is datetime, and create a new datetime with the hour and minute?

DateTime starttime = (DateTime)dtSAC.Rows[0]["starttime"];
int hours = int.Parse(_tbStartTimeHour.Text );
int minutes = int.Parse(_tbStartTimeMinute.Text);
DateTime r = new Datetime(starttime.Year, starttime.Month, starttime.Day).AddHours(hours).AddMinutes(minutes);

Open in new window


untested code, might have typos ...
ASKER CERTIFIED SOLUTION
Avatar of Carlos Villegas
Carlos Villegas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, It looks like angel solution :p
yup, except that I wrote, by practice, in several lines of code.
this is because I want to be able to know on which assignment the error actually occurs, if any.