DateTime now = Datetime.Now; DateTime 2daysAgo = now.AddDays(-2); DateTime 2daysLater = now.AddDays(2);
int offset = 2 ; DateTime past = DateTime.Now.AddDays(-offset); DateTime future = DateTime.Now.AddDays(offset);
// required using System.Linq; // generate range: -2,-1,0,1,2 private IEnumerable<int> FourDays = Enumerable.Range(-2, 5); // somewhere in a method DateTime rightNow = DateTime.Now; // test ... foreach (var i in FourDays) { // test ... Console.WriteLine(rightNow.AddDays(i)); // call method to get Records // ... }</int>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)