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

x
?
Solved

converting datetime to stop sql error?

Posted on 2013-06-26
8
Medium Priority
?
513 Views
Last Modified: 2013-09-06
HI:
I have a little delphi program interrogating an mssql database.
I have a calendar control but when I select a date I get a sql error "DateTime field overflow. Fractional second precision exceeds the scale specified in the parameter binding." Which I took to mean that I am trying to filter a date with a date time?
Attached sql query sets out what I think the issue is. field 'datet' in 'vvdates' is datetime. Field 'ordered' in 'goorders' is a date.
Having said all of that the program actually works on the PC on which I am writing the program. It fails on any other PC with the sql error as described. I have checked the ODBC links and BDE on all PC's and they look the same. Has anybody experience of this?
Thanks!
delphidate.txt
0
Comment
Question by:ClaytonGlass
[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
8 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 39278172
First of all I'd stop using odbc for MSSql. You could simply use ADO  to connect directly using the OS native engine

Anyway try using DateTimePicker.date instead of Datetimepicker.datetime.
0
 

Author Comment

by:ClaytonGlass
ID: 39278231
Thanks for that. I tried date and got 'invalid date format message'. Will look at ADO.
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 39279079
Try this as well

Query1.ParamByName('SELDATE').AsSqlTimeStamp := DateTimeToSQLTimeStamp(DateTimePicker1.Date);
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ClaytonGlass
ID: 39280508
Thanks ewangoya but get a pascal error  - undeclared identifier. AM using BDS2006 if that helps.
0
 
LVL 28

Accepted Solution

by:
Sinisa Vuk earned 600 total points
ID: 39284543
Try
Query1.ParamByName('SELDATE').AsDatetime := Trunc(DateTimePicker1.Date); 

Open in new window

0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 39470066
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 

Author Comment

by:ClaytonGlass
ID: 39470063
I do apologise.
I switched to Ado and then became distracted by a different issue.
Am awarding the points to sinisav as his solution works now.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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 Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

604 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