Solved

Date in MS SQL statement

Posted on 1998-10-29
6
245 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now