Get set properties remove time from date and time

How to remove temporary part from DateTime inside Get Set Properties

The following code does not work, and I tried several ways. I also tried dateValue.ToString("d")

 private DateTime dateValue; public DateTime DateValue { get { //First Try return dateValue.ToShortDateString; //Second Try return dateValue.ToString("d") //Third Try DateTime dateValue = DateTime.????(not sure) } } 
+4
source share
2 answers

You can use the Date property.

 DateTime dateValue = dateValue.Date; 

So it will be

 private DateTime dateValue; public DateTime DateValue { get { return dateValue.Date; } } 
+6
source

Are you looking for Date :

 return dateValue.Date; 
+5
source

Source: https://habr.com/ru/post/1489758/


All Articles