D
denkyira
Guest
I want to get the first, second and third Monday of the Month between two dates. I can get the first Monday of the month but not between two day. Below is my code. Any help will be appreciated.
class Program
{
public class BusinessWeekDays
{
public DateTime Tuesday;
public DateTime Monday;
}
static void Main(string[] args)
{
var StartDate = DateTime.Parse("04/25/2019");
var SeriesEndDate = DateTime.Parse("09/30/2019");
for (int mth = 1; mth <= 12; mth++)
{
DateTime dt = new DateTime(2010, mth, 1);
while (dt.DayOfWeek != DayOfWeek.Monday)
{
dt = dt.AddDays(1);
}
Console.WriteLine(dt.ToLongDateString());
}
Console.ReadLine();
//for (var i = StartDate; i < SeriesEndDate; i = i.AddMonths(Monthly))
//{
// months.Add(new BusinessWeekDays { Tuesday = dt, Monday = dt.AddDays(7) });
// Console.WriteLine(months);
//}
}
Ebenezer
Continue reading...
class Program
{
public class BusinessWeekDays
{
public DateTime Tuesday;
public DateTime Monday;
}
static void Main(string[] args)
{
var StartDate = DateTime.Parse("04/25/2019");
var SeriesEndDate = DateTime.Parse("09/30/2019");
for (int mth = 1; mth <= 12; mth++)
{
DateTime dt = new DateTime(2010, mth, 1);
while (dt.DayOfWeek != DayOfWeek.Monday)
{
dt = dt.AddDays(1);
}
Console.WriteLine(dt.ToLongDateString());
}
Console.ReadLine();
//for (var i = StartDate; i < SeriesEndDate; i = i.AddMonths(Monthly))
//{
// months.Add(new BusinessWeekDays { Tuesday = dt, Monday = dt.AddDays(7) });
// Console.WriteLine(months);
//}
}
Ebenezer
Continue reading...