Link to home
Start Free TrialLog in
Avatar of hansmtbank
hansmtbank

asked on

Date in MS SQL statement

Hi!
I try to execute MS SQL statement.

insert MyTable (MyDate, MyValue) values (10/30/1998, 2.5)

"Operand type clash: int is incompatible with datetime"

Please help me! How can I insert date field in SQL statemanet?
Avatar of dwwang
dwwang

The good way to do this is using parameter:

insert MyTable (MyDate, MyValue) values (:mydate, 2.5)

then:

yourquery.parambyname('mydate').asdatetime:=mydate;
Avatar of hansmtbank

ASKER

No, I can't use parameters.
Why not? can you give some details?
Thank you! I inserted date as "dd.mm.yyyy". I have to setup date format on MS SQL server.
ASKER CERTIFIED SOLUTION
Avatar of David Williams
David Williams
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dates normally have to be quoted '10/30/1998'.

Also the default language date format of the user you are logged in as applies.

Use Instlang.sql on the MS SQL Install cd to install diferent languages...

Use the sp_setlanguage or sp_setdefaultlanguage to set which language is used by which user.

One last note.  Consider using long dates to make the app international.

ie use "30 October 1998"..

hope this helps..