I need to know how I would obtain the last Monday of each month, since in the program that I have to do, that last Monday of each month I must generate interest, but I don't know how I could calculate it.
try to get the total days of the month and subtract 7 days but obviously the result will not always be a Monday.
DateTime fechaHoy = (DateTime)fechahoy.Value.Date;
DateTime fechabono = FechaAbono.Value.Date;
int anyo = fechabono.Year;
int mes = fechabono.Month;
int dias = DateTime.DaysInMonth(anyo, mes);
int anyoHoy = fechaHoy.Year;
int mesHoy = fechaHoy.Month;
int diasHoy = DateTime.DaysInMonth(anyoHoy, mesHoy);
int totaldiashoy = DateTime.DaysInMonth(anyoHoy, mesHoy);// 31 dias
int totaldias = totaldiashoy - 7;