Returns the date part of the DateTime structure - CSharp System

CSharp examples for System:DateTime Calculate

Description

Returns the date part of the DateTime structure

Demo Code


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

public class Main{
        /// <summary>
        /// Returns the date part of the DateTime structure
        /// </summary>
        /// <param name="source">The t.</param>
        /// <returns></returns>
        public static DateTime ToDate(this DateTime source)
        {
            return new DateTime(source.Year, source.Month, source.Day);
        }
}

Related Tutorials