End Of Month - CSharp System

CSharp examples for System:DateTime Month

Description

End Of Month

Demo Code



public class Main{
        public static DateTime EndOfMonth(this DateTime value)
        {/*from ww  w. j  a  v a  2  s . c o m*/
            var retVal = value.StartOfMonth();

            retVal = retVal.AddMonths(1).AddDays(-1);
            return new DateTime(retVal.Year, retVal.Month, retVal.Day, 23, 59, 59);
        }
        public static DateTime StartOfMonth(this DateTime value)
        {
            return new DateTime(value.Year, value.Month, 01, 0, 0, 0);
        }
}

Related Tutorials