Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Datatype problem on insert and update

Status
Not open for further replies.

LLudlow

Programmer
Joined
Oct 5, 2001
Messages
186
Location
CA
I am trying to save a date from a VB 6.0 form to a SQL server database. The datatype for the form is Date and the datatype for the Database is datetime. When i try to save the date to the database it becomes 1/1/1900. But the appropriate variable in the sql statement is showing the correct date but when it is entered into the table it gets changed. But in reverse if i enter the dat into the database then it displays correctly on the form. Am i doing something wrong with the datatypes?

Thanks
 
I know what the problem is but i do not know how to fix it.
When i am inserting into the table there has to be quotes around the date so in my sql goes something like this:

chr(39) & date & chr(39)

this works fine when there is a real date in the textbox but when it is empty i try to pass Null as the value but when this is inserted into the SQL statement it is turned into "Null" which is not accepted by the database. So instead the field in the database becomes 1/1/1900.

Does anyone know a simple way to resolve this?

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top