WebApr 9, 2015 · I'm given two dates, a start date and an end date and on a specified interval I need to take some action. For example: for every date between 3/10/2009 on every third day until 3/26/2009 I need to create an entry in a List. So my inputs would be: DateTime StartDate = "3/10/2009"; DateTime EndDate = "3/26/2009"; int DayInterval = 3; WebOct 7, 2024 · List datelist=new List(); while (dt1 <= dt2) { datelist.Add(dt1); dt1 = dt1.AddDays(1); } DateTime[] dates = datelist.ToArray(); Marked as answer byAnonymousThursday, October 7, 2024 …
c# - Find missing dates for a given range - Stack Overflow
WebFeb 14, 2011 · DateTime dtFrom = new DateTime (2011, 02, 5); DateTime dtTo = new DateTime (2011, 02, 9); List days = new List (); while (dtTo != dtFrom) { dtFrom = dtFrom.AddDays (1); days.Add (dtFrom.DayOfWeek); } days would have your week days list (if this is what you intent to have) Share Improve this answer Follow WebMar 5, 2016 · 2 Answers. You can generate a list of dates as explained in Create an array or List of all dates between two dates: public List GetDatesBetween (DateTime start, DateTime end) { var dates = Enumerable.Range (0, 1 + end.Subtract (start).Days) .Select (offset => start.AddDays (offset)) .ToList (); return dates; } adjective quizizz
c# - Get dates on certain weekday between two dates - Stack Overflow
WebMar 25, 2024 · You can print the dates with these methods: Method 1: allFriday.ForEach (x => Console.WriteLine (x.ToShortDateString ())); Method 2: foreach (var friday in allFriday) { Console.WriteLine (friday.ToShortDateString ()); } Method 3: for (var i = 0; i < allFriday.Count (); i++) { Console.WriteLine (allFriday [i].ToShortDateString ()); } WebJan 4, 2010 · DateTime currentDate = new DateTime (2010, 1, 1); DateTime endDate = new DateTime (2010, 1, 6); List existingDates = new List; //You fill with values List missingDates = new List; while (currentDate <= endDate) { if (existingDates.contains (currentDate)) missingDates.Add (currentDate); //Increment date currentDate = … WebAug 10, 2024 · Get List of Dates between two dates using C# and VB.Net in ASP.Net Waghmare SOLVED Posted: on Aug 10, 2024 09:08 AM Forum: Data Controls Answer: 1 Views: 8981 Sample Code: Download Hi Team, I have data like as below. Start Date and End Date example : [5 days interval ] Start date = 11-Aug-2024 End date = 25-Nov-2024 jr 列車の旅