how to convert datetime to short date?
You must call .ToString()
method with that format that you want. In your example it will be like this.
DateTime date=DateTime.Now;
var shortDate=date.ToString("yyyy-MM-dd");
Or if you want to keep DateTime
type, you must call .Date
property of DateTime
DateTime date=DateTime.Now;
var shortDate=date.Date;
From MSDN
A new object with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).
DateTime dateToDisplay = new DateTime(2014, 11, 03, 42, 50);
String shortDateTime = dateToDisplay.ToShortDateString();
Then you can convert this shortDateTime to datetime like this
DateTime shortDate = Convert.ToDateTime(shortDateTime);