Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Set Properties remove time from datetime

Tags:

c#

asp.net

How do I remove time portion from DateTime within Get Set Properties

The below code is not working and I tried a few 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)
    }
}
like image 712
Jay Avatar asked Dec 20 '22 03:12

Jay


1 Answers

You can use the Date property.

DateTime dateValue = dateValue.Date;

So it would be

private DateTime dateValue;

public DateTime DateValue
{
   get
   {          
      return dateValue.Date;
   }
}
like image 57
keyboardP Avatar answered Dec 30 '22 04:12

keyboardP