Solved

converting datetime to stop sql error?

Posted on 2013-06-26
8
487 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
8 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
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
Comment Utility
Thanks for that. I tried date and got 'invalid date format message'. Will look at ADO.
0
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility
Try this as well

Query1.ParamByName('SELDATE').AsSqlTimeStamp := DateTimeToSQLTimeStamp(DateTimePicker1.Date);
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:ClaytonGlass
Comment Utility
Thanks ewangoya but get a pascal error  - undeclared identifier. AM using BDS2006 if that helps.
0
 
LVL 25

Accepted Solution

by:
Sinisa Vuk earned 200 total points
Comment Utility
Try
Query1.ParamByName('SELDATE').AsDatetime := Trunc(DateTimePicker1.Date); 

Open in new window

0
 
LVL 36

Expert Comment

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

Not enough information to confirm an answer.
0
 

Author Comment

by:ClaytonGlass
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

16 Experts available now in Live!

Get 1:1 Help Now