Community discussion forum

Eliminating "1/1/1900" in datetime fields....

  • 1 year ago

    when storing a record all the the EMPTY value of datetime field are storing as "1/1/1900". How can we avoid this and store "NULL" value while user insert or update a record?
    ( i inserted the record via ASP.NET with C# )

  • 1 year ago

    If the database is set up to allow nulls in the datetime field then, depending upon how you set up the insert statement (inline, stored proc, etc):

    you simply need to set the parameter value going through to Sql to be "DbNull.Value" or if inline, use "null" as the value - as in "insert xyz(dt) values (null)"

    HTH,

    Joe 

  • 1 year ago

    i m inputting from ASP.NET with C# coding to SQL server (version 2003, 1.1 framework).

    when i insert or update this 1/1/1900 is getting inserted to the database....

    is there any trigger to eliminate this problem? (i.e.. while inserting or updating to a particular table, the trigger should execute and insert the NULL value to the DATETIME fields which contains 1/1/1900)

  • 1 year ago

    To be fair, yes, a trigger would work without problem - but only if the column allows nulls. Other than that, if yiou want to do it in the application rather than the database, you'd have to check the datetime value in the code and do as I suggested in my previous post.

    Codes always helpful here.

    Joe 

  • 1 year ago

    sorry i didnt analyse about this my friend.

    but the thing is "DATETIME field will accept NULL"

  • 1 year ago

    Ok,

    So lets see the code you're working with.

    Joe 

  • 1 year ago

    sorry my friend.this trigger concept is just an idea of my TEAM LEADER. i m not that much strong in SQL... do the favour plz

  • 1 year ago

    Have a look here: http://msdn2.microsoft.com/en-us/library/aa213995(SQL.80).aspx

    Joe 

  • 1 year ago

    IS THERE ANYONE HERE TO GIVE ME CODING TO REMOVE 1/1/1900 in database and to insert NULL???????????????????????????????????

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback