Let's say I have the following DateTime
which has a value of: "2017-01-27T00:00:00"
.
How can I remove the above date to return only the date without the time and without changing the format? i.e return "2017-01-27"
Let's say I have the following DateTime
which has a value of: "2017-01-27T00:00:00"
.
How can I remove the above date to return only the date without the time and without changing the format? i.e return "2017-01-27"
Something like this maybe?
var dt = DateTime.Parse("2017-01-27T00:00:00");
return dt.ToString("yyyy-MM-dd");
If you need some customization for the date, you can use *name*.ToString('yyyy-MM-dd')
to customize the result. See the documentation here