Reputation: 365
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"
Upvotes: 1
Views: 2445
Reputation: 1125
If you need some customization for the date, you can use *name*.ToString('yyyy-MM-dd')
to customize the result. See the documentation here
Upvotes: 0
Reputation: 973
Something like this maybe?
var dt = DateTime.Parse("2017-01-27T00:00:00");
return dt.ToString("yyyy-MM-dd");
Upvotes: 3