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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Impossible date insertion?

Status
Not open for further replies.

AndWy

Programmer
Mar 13, 2001
13
0
0
GB
I am trying to insert a date into sql Server 2000.
I am using the INSERT...VALUES in an SQL statement with VB, But I keep getting the message that SQL cannot convert char to smalldate.
This is hacking me off!!

This is an example of code that does not work -
INSERT INTO someTable(cName, cDate)
VALUES('anyName', CONVERT(DATETIME, ' 2001 - 07 - 26 00:00:00', 102))

Is there another way?
 
Hi AndWy,
You are facing the problem because of the format
yyyy-mm-dd.
There are many ways to get rid of this problem, But i feel the best way is
SET DATEFORMAT YMD --Issue this command so that sql will use yyyy/mm/dd format for the particular user session.
INSERT ... VALUES ("'"+myDateValue+"'") --Just make sure that you are having myDateValue in yyyy/mm/dd format.

If you still face problem, just let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top