I can’t believe how long it’s taken me to fail at finding the answer to this seemingly obvious question.
Date SomeRandomMadeUpDate = DateTime.Now.AddMonths(randomMonths).Date;
Cannot implicitly convert type ‘System.DateTime’ to ‘System.Date’
I can even call:
Date.Now
but calling .AddDays on it returns a DateTime.
Again, the question is: How do I turn a C# DateTime into a C# Date
I had to look it up, because I didn’t know there was a Date-type in .NET 4.0, but apparently there is one in System.Dataflow.dll. Just use the constructor, with the DateTime as the argument: