Mọi người giúp mình bài toàn. Lấy ngày cuối cùng của tháng đó hoặc tháng trước. Và tổng số ngày của tháng đó giúp mình với. Mình sử dụng web asp.net code C# ý mà không biết làm sao? Cảm ơn Mọi người.
Của bạn đây: Code lấy ngày cuối cùng trong tháng. Mã: public static DateTime LayNgayCuoiCungCuaThang(DateTime dtInput) { DateTime dtResult = dtInput; dtResult = dtResult.AddMonths(1); dtResult = dtResult.AddDays(-(dtResult.Day)); return dtResult; } Lấy ngày cuối cùng của tháng trước đó Mã: public static DateTime NgayCuoiCungCuaThangTruoc(DateTime dtInput) { DateTime dtResult = dtInput; dtResult = dtResult.AddDays((-dtResult.Day)); return dtResult; } Lấy tổng số ngày trong tháng Mã: public static int NgayTrongThang(DateTime dtInput) { DateTime dtResult = dtInput; dtResult = dtResult.AddMonths(1); dtResult = dtResult.AddDays(-(dtResult.Day)); return dtResult.Day; } Lấy ngày đầu tiên của tháng Mã: public static DateTime NgayDauTienCuaThang(DateTime dtInput) { DateTime dtResult = dtInput; dtResult = dtResult.AddDays((-dtResult.Day)+1); return dtResult; }