I have an asp.net calendar control that is used to select a date and store it in a database. It is also adding the time which makes reporting difficult. We only need the date not the time. How can I prevent the calendar control from including the time….or making the time the same for every date?
Share
DateTime has a Date property,
DateTime.Datethat will return just the date with 00:00:00 for the time.So, when reading the calendar.SelectedDate, use
calendar.SelectedDate.Date. This still returns a DateTime but with a zeroed time.When rendering a DateTime without the time, use ToString(“dd/mm/yyyy”).