Sir,
Pls. suggest that how to insert 31-12-9999 date in sql server
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
DarilPosted Nov 18, 2021, 7:37 AM
Unless you are inserting it as a string the date is not formatted, that is the internal representation has no notion of 'format'.
Monika SinghPosted Nov 7, 2014, 12:42 AM
VulpesPosted Nov 5, 2014, 4:47 AM
http://msdn.microsoft.com/en-gb/library/ms186724.aspx
I've always found personally that you have least problems with dates (different cultures etc) if you insert them in the format yyyy-MM-dd.
So this should work:
DateTime dt = new DateTime(9999, 12, 31);
and then use: "'" + dt.ToString("yyyy-MM-dd") + "'" in your INSERT command or, better still, use a parameter so you don't have to worry about this stuff.
Joginder BangerPosted Nov 5, 2014, 4:31 AM