This:
dtpFrom.DisplayDate = DateTime.Now -1;
(which is how it was done in Delphi), does not work; I get, “Operator ‘-‘ cannot be applied to operands of type ‘System.DateTime’ and ‘int'”
Update: OK, I see I can do this, although I don’t know if this is the most succinct way:
int dtYear = DateTime.Now.Year;
int dtMonth = DateTime.Now.Month;
int dtDay = DateTime.Now.Day;
dtpFrom.SelectedDate = new DateTime(dtYear, dtMonth, dtDay - 1);
…and now I see there is a better way, but must wait a minute before selecting a correct answer.
1 Answer