I have a textbox without calendar control and we will call it as publication year(we use diff name in our project). The publication year is 1999, 2001 or 1860.
My step goes like this
I have datetime in my database.(unchangable)
I am using C# and sql server 2005.
string date = textBox1.text;
Datetime dt = Convert.ToDateTime(date);
I pass dt to my database using dynamic sql
to trick the code, I added a prefix 1/1/ before my entered date like 1/1/2010 , it worked well
Now my TL asked me not to do like that…. I am ??? . Please help
As a note, if you only care about the year then I would highly suggest that the database field should be an Int instead of a DateTime.
The minimum sql datetime value is 1/1/1753 for a number of reasons that you can certainly look up. However, the point is that a regular DateTime field is storing way more information than you care about.
So if you deal with publications older than 1753 you’re going to run into an architectural issue. And, if somehow you didn’t, you’d certainly run into issues deciding if a publication was 280 years old or 279 or 281…