Visual C# Developer Center > Visual C# Forums > Visual C# General > MinDate not updating in SQL 2008 Date
Ask a questionAsk a question
 

AnswerMinDate not updating in SQL 2008 Date

  • Friday, November 06, 2009 5:34 PMNoEgo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    this is weird.  Any other date works, but when I send back MinDate  1/1/0001 12:00:00 AM to SQL 2008's Date field, it remains the default which I have set to null in the databse for that field:

    conn.AddParam("@birthDate", birthDate);

    birthDate is type DateTime.  It's set to DateTime.MinValue;  I don't see why it wouldn't take this.
    C# Web Developer

Answers

  • Friday, November 06, 2009 5:42 PMChris Fo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    1/1/0001 is an unknown value to SQL Server.
    DECLARE @t DATETIME = '1/1/0001'
    SELECT @t
    
    
    Msg 242, Level 16, State 3, Line 1

    The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    But this works:

    DECLARE @t DATETIME = '1/1/1753'
    SELECT @t
    
    

    1753-01-01 00:00:00.000

    • Marked As Answer byNoEgo Friday, November 06, 2009 5:53 PM
    •  

All Replies

  • Friday, November 06, 2009 5:42 PMChris Fo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    1/1/0001 is an unknown value to SQL Server.
    DECLARE @t DATETIME = '1/1/0001'
    SELECT @t
    
    
    Msg 242, Level 16, State 3, Line 1

    The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    But this works:

    DECLARE @t DATETIME = '1/1/1753'
    SELECT @t
    
    

    1753-01-01 00:00:00.000

    • Marked As Answer byNoEgo Friday, November 06, 2009 5:53 PM
    •