Converts from SqlServer min date to DateTime.MinValue if required. - CSharp System

CSharp examples for System:DateTime Convert

Description

Converts from SqlServer min date to DateTime.MinValue if required.

Demo Code


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

public class Main{
        /// <summary>
        /// Converts from SqlServer min date to <c>DateTime.MinValue</c> if required.
        /// </summary>
        /// <param name="dateTime">Date/Time in sqlServer</param>
        /// <returns>Proper .NET date</returns>
        public static DateTime ToSqlServer(this DateTime dateTime)
        {
            return dateTime == DateTime.MinValue ? new DateTime(1753, 1, 1) : dateTime;
        }
}

Related Tutorials