A quick expression anyone please?
var now = DateTime.Now;    
var firstDayCurrentMonth = new DateTime(now.Year, now.Month, 1);
var lastDayLastMonth = firstDayCurrentMonth.AddDays(-1);
                        DateTime now = DateTime.Now;
DateTime lastDayOfLastMonth = now.Date.AddDays(-now.Day);
                        Try the DateTime.DaysInMonth(int year, int month) method
Here's an example:
DateTime oneMonthAgo = DateTime.Now.AddMonths(-1);
int days = DateTime.DaysInMonth(oneMonthAgo.Year, oneMonthAgo.Month);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With