George George

George George

  • NA
  • 778
  • 0

yesterday's time

Jun 5 2008 9:28 PM

Hello everyone,


I want to get the same time in yesterday, is there any bug in my below code?

My concern is code, _CurrentDate.Now.Day - 1, if current date is 1, 1 minus 1 is zero, not a valid date?

<pre>
        DateTime _CurrentDate = DateTime.Now;
        DateTime _LastDate = new DateTime(_CurrentDate.Now.Year, _CurrentDate.Now.Month, _CurrentDate.Now.Day - 1, _CurrentDate.Now.Hour, _CurrentDate.Now.Second);
</pre>


thanks in advance,
George


Answers (18)