Gets the first day of month. - CSharp System

CSharp examples for System:DateTime Month

Description

Gets the first day of month.

Demo Code


using System;/*from  ww  w .java 2s  .  c o  m*/

public class Main{
        /// <summary>
        ///     Gets the first day of month.
        /// </summary>
        /// <param name="date">The date.</param>
        /// <returns></returns>
        public static DateTime GetFirstDayOfMonth(this DateTime date)
        {
            var firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
            return firstDayOfMonth;
        }
}

Related Tutorials