?
Solved

Date in MS SQL statement

Posted on 1998-10-29
6
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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.

 

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 100 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 19 hours left to enroll

752 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