date calculations in c#
//week of month calculations
var dt = Convert.ToDateTime("2021-06-05");
for (var t = 1; t < 30; t++)
{
dt = dt.AddDays(1);
decimal numberofday = dt.Day;
decimal d = (Math.Floor(numberofday / 7)) + 1;
var weekofmonth = 0;
if ((numberofday) % 7 == 0)
{
weekofmonth = Convert.ToInt32((d)) - 1;
}
weekofmonth = Convert.ToInt32(d);
}