CSharp examples for System:DateTime Day
Returns the last day of the current month.
using System.Globalization; using System.Text; using System.Linq; using System.Collections.Generic; using System;// w ww . j av a 2s.c om public class Main{ /// <summary> /// Returns the last day of the current month. /// </summary> /// <returns></returns> public static DateTime EndOfMonth() { return EndOfMonth(DateTime.UtcNow); } /// <summary> /// Returns the last day of the month. /// </summary> /// <param name="d"></param> /// <returns></returns> public static DateTime EndOfMonth(DateTime d) { DateTime n = new DateTime(d.Year, d.Month + 1, 1, 23, 59, 59); return n.AddDays(-1); } }