• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

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?
0
hansmtbank
Asked:
hansmtbank
1 Solution
 
dwwangCommented:
The good way to do this is using parameter:

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

then:

yourquery.parambyname('mydate').asdatetime:=mydate;
0
 
hansmtbankAuthor Commented:
No, I can't use parameters.
0
 
dwwangCommented:
Why not? can you give some details?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
hansmtbankAuthor Commented:
Thank you! I inserted date as "dd.mm.yyyy". I have to setup date format on MS SQL server.
0
 
davidmwilliamsCommented:
 I think you seem to have solved it yourself ... your problem is because either you haven't defined the field as a date/time in the underlying database, or because you are trying to store a date in the field in a format other than what you've specified in SQL Server.
  Check both these things, and all will go ok.
0
 
KirkGrayCommented:
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..





0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now