Question Inserting Dates into MSSQL DB

ChrisMayhew

Member
Joined
Apr 2, 2009
Messages
12
Programming Experience
1-3
Hello Guys

I am trying to insert a date into a MSSQL database which is set to a DateTime field but it always inserts in at 01/01/1900

I am using a masked text box that is set to the short date mask.


Any ideas?

Also when I try to set a default date on a datetime field it will also insert as 01/01/1900 so how do I get around that?

Thanks,
Chris
 
First up, please post in the most appropriate forum for the topic of your thread. Moved.

With regards to the question, is there a particular reason you're not using a DateTimePicker? It handles all formatting, validation and conversion for you. You simply get and set the Value property with a Date value. As a result it's usually the best choice.

Apart from that, we'd have to see what you're doing to know what you're doing wrong. How exactly are you getting the value from the control to the database?
 
Read the PQ link in my signature; parameterize your query and ensure youre submitting a date, not text-that-looks-like-a-date
 
Back
Top