Solved

converting datetime to stop sql error?

Posted on 2013-06-26
8
498 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
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:ewangoya
ID: 39279079
Try this as well

Query1.ParamByName('SELDATE').AsSqlTimeStamp := DateTimeToSQLTimeStamp(DateTimePicker1.Date);
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

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

Accepted Solution

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

Open in new window

0
 
LVL 37

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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