Method for getting first day in month - CSharp System

CSharp examples for System:DateTime Month

Description

Method for getting first day in month

Demo Code


using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System;//from   ww w.  j  a v a 2s  . c o m

public class Main{
        /// <summary>
        /// Method for getting first day in month
        /// </summary>
        /// <param name="date">Date</param>
        /// <returns>First day in month</returns>
        public static DateTime GetFirstDay(this DateTime date)
        {
            return new DateTime(date.Year, date.Month, 1);
        }
}

Related Tutorials