Method for getting previous month - CSharp System

CSharp examples for System:DateTime Month

Description

Method for getting previous month

Demo Code


using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System;//  w  w w .j  a  va2  s .  c o  m

public class Main{
        /// <summary>
        /// Method for getting previous month
        /// </summary>
        /// <param name="date">Date</param>
        /// <returns>Previous mouth</returns>
        public static DateTime GetPreviousMonth(this DateTime date)
        {
            return date.AddMonths(-1);
        }
}

Related Tutorials