Reputation:
DateTime strat=new DateTime();
strat=dateTimePickerStart.Value.ToString("MM/dd/yyyy");
how i can covert the type of the dateTimePicker value to dateTime type
Upvotes: 0
Views: 152
Reputation: 91
You are converting your dateTimePicker's value to a string which can't be assigned to a variable of type DateTime.
Options:
strat=dateTimePickerStart.Value;
or if you want to format the date as you have shown, it could be parsed:
strat=DateTime.Parse(dateTimePickerStart.Value.ToString("MM/dd/yyyy"));
however, to remove the time component this would be better:
strat=dateTimePickerStart.Value.Date;
Upvotes: 1