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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 4, 2014, 11:47 PM EST
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 BangerRank #360 · 7K reputationPosted Nov 4, 2014, 11:31 PM EST
Monika Singh7 reputationPosted Nov 6, 2014, 7:42 PM EST
Daril148 reputationPosted Nov 18, 2021, 2:37 AM EST
Unless you are inserting it as a string the date is not formatted, that is the internal representation has no notion of 'format'.
DateTime xx = DateTime.Now; string change = "dd-mm-yyyy"; string insert = xx.ToString(change);