Last Date Of Month - CSharp System

CSharp examples for System:DateTime Month

Description

Last Date Of Month

Demo Code


using System.Globalization;
using System;/* www  . j a  v  a  2s  .  c  o  m*/

public class Main{
        public static DateTime LastDateOfMonth(this DateTime date)
        {
            return date.FirstDateOfMonth().AddMonths(1).AddDays(-1).Date;
        }
        public static DateTime FirstDateOfMonth(this DateTime date)
        {
            return date.AddDays(date.Day*-1 + 1).Date;
        }
}

Related Tutorials