Gets the end of month. - CSharp System

CSharp examples for System:DateTime Month

Description

Gets the end of month.

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;// w  w w  .  ja va 2 s .c o m

public class Main{
        /// <summary>
        /// Gets the end of month.
        /// </summary>
        /// <returns>The end of month.</returns>
        /// <param name="value">The DateTime it self.</param>
        public static DateTime GetEndOfMonth(this DateTime value)
        {
            return new DateTime(value.Year, value.Month, DateTime.DaysInMonth(value.Year, value.Month), 23, 59, 59, 999);
        }
}

Related Tutorials