To Month Start - CSharp System

CSharp examples for System:DateTime Month

Description

To Month Start

Demo Code


using System;/* w w  w  .j a  va 2 s.c  o  m*/

public class Main{
        public static DateTime ToMonthStart(this DateTime value)
        {
            return new DateTime(value.Year, value.Month, 1);
        }
        public static DateTime ToMonthStart(this string value)
        {
            DateTime date = Convert.ToDateTime(value);
            return new DateTime(date.Year, date.Month, 1);
        }
}

Related Tutorials