Solved

Date in MS SQL statement

Posted on 1998-10-29
6
253 Views
Last Modified: 2010-04-06
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
Comment
Question by:hansmtbank
6 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345009
The good way to do this is using parameter:

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

then:

yourquery.parambyname('mydate').asdatetime:=mydate;
0
 

Author Comment

by:hansmtbank
ID: 1345010
No, I can't use parameters.
0
 
LVL 4

Expert Comment

by:dwwang
ID: 1345011
Why not? can you give some details?
0
Technology Partners: 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!

 

Author Comment

by:hansmtbank
ID: 1345012
Thank you! I inserted date as "dd.mm.yyyy". I have to setup date format on MS SQL server.
0
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 50 total points
ID: 1345013
 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
 

Expert Comment

by:KirkGray
ID: 1345014
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question