Convert DateTime to date only inside a class

  • Thread starter Thread starter DoctorWhoKnew
  • Start date Start date
D

DoctorWhoKnew

Guest
I have a DateTime type where I only want the date, not the time. Here is the class where I define a DateTime object.

public class MovingAverage
{
public DateTime Date { get; set; }
public decimal Close { get; set; }

}

The following does not give an error:

var values = stocks.Select(s => new MovingAverage() { Date = s.Date.Date, Close = s.Close });
var movingAverageQueue = new Queue<MovingAverage>(values);


But, s.Date.Date gives me the date and time, not the date only part I expect.

Continue reading...
 
Back
Top