I have a Datetime object and I want to remove time part from it. I tried the following line of code but still auth.dob contains time. How can I just set 2017-01-01 in it?
auth.dob = Convert.ToDateTime("2017-01-01").Date;
Sadly .Net does not include a type that only stores the date. Generally we use DateTime and set the time to midnight. Then when you output the value you just omit the Time when displaying it see DateTime.ToString(string), DateTime.ToShortDateString() and DateTime.ToLongDateString().
While this works it does lead to all sorts of confusion. I've often felt it would have been better to have a Date struct a Time struct and a DateTime struct that was a composition of the other two. But sadly that isn't the case.
There is the Noda Time library, but that is probably overkill in this case.
Alternatively you can role your own and store the day, month and year as separate numeric variables.
DateTimeobject has time properties. Its name implies this. Why do you think you need to do this? What are you actually trying to accomplish here?auth.dobstill contains time?