Does SQLs built-in DateTime type has any merits over nvarchar type?
If it were you , which one would you use?
I need to store dates in my SQLServer database and I’m curious to know which one is better and why it is better.
I also want to know what happens if I for example store dates as string literals (I mean nvarchar )? Does it take longer to be searched? Or they are the same in terms of performance ?
And for the last question. How can I send a date from my c# application to the sql field of tye DateTime? Is it any different from the c#s DateTime ?
You’re given a
datedatetype for a reason, why would you not use it?What happens when you store “3/2/2012” in a text field? Is it March 2nd? Is it February 3rd?
Store the date in a
dateordatetimefield, and do any formatting of the date after the fact.EDIT
If you have to store dates like
1391/7/1, your choices are:datetime2data type; it allows dates earlier than 1753/01/01 (which is whatdatetimestops at).