Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date in MS SQL statement

Posted on 1998-10-29
6
Medium Priority
?
272 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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