typically when I have a timepicker and a datePicker on a winform I combine the two into one date object by using the new DateTime (y,m,d,h,mi,s) constructor. this seems kind of long winded, and I was wondering what approach others are using if faced with this situation.
DateTime date =
new DateTime(DatePicker.Value.Year, DatePicker.Value.Month, DatePicker.Value.Day,
TimePicker.Value.Hour, TimePicker.Value.Minute, TimePicker.Value.Second);
looks like it was just a simple.
DateTime date = DatePicker.Value.Date.Add(TimePicker.Value.TimeOfDay);
I didn't realize
hope you have used DateTimePicker for selecting Date and Time. in this case you can combine date and time like
DateTime date = DatePicker.Value.Date + TimePicker.Value.TimeOfDay;
Have you tried DateTimePicker ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With