Returns 12:59:59pm time for the date passed. Useful for date only search ranges end value - CSharp System

CSharp examples for System:DateTime Time

Description

Returns 12:59:59pm time for the date passed. Useful for date only search ranges end value

Demo Code


using System;/*from  w  w w.  jav  a  2 s .c  o m*/

public class Main{
        /// <summary>
        /// Returns 12:59:59pm time for the date passed.
        /// Useful for date only search ranges end value
        /// </summary>
        /// <param name="date">Date to convert</param>
        /// <returns></returns>
        public static DateTime EndOfDay(this DateTime date)
        {
            return date.Date.AddDays(1).AddMilliseconds(-1);
        }
}

Related Tutorials