Last Date Of Quarter - CSharp System

CSharp examples for System:DateTime Quarter

Description

Last Date Of Quarter

Demo Code


using System.Globalization;
using System;//w  w w . ja  v  a 2  s . c o  m

public class Main{
        public static DateTime LastDateOfQuarter(this DateTime date)
        {
            return date.FirstDateOfQuarter().AddMonths(3).AddDays(-1);
        }
        public static DateTime FirstDateOfQuarter(this DateTime date)
        {
            var quarter = date.Quarter();
            var month = (quarter - 1)*3 + 1;
            return new DateTime(date.Year, month, 1);
        }
}

Related Tutorials