I’m working in a WinForm and have two Date Time Pickers: One that displays a short date and one that displays time. In my SQL DB, I have a DateTime field that I would like to populate using the two values of my DTPs put together.
This is what I have currently: (that isn’t working)
myDateTimeField = Convert.ToDateTime(dtp_date.Text + dtp_time.Text);
Any ideas how to fix that?
Use the
DateTimeAddmethod on the firstDateTimePicker‘sDateproperty, passing theTimespanreturned by the secondDateTimePicker‘sTimeOfDayproperty.