Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

converting datetime to stop sql error?

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
ClaytonGlass
Asked:
ClaytonGlass
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
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
 
ClaytonGlassAuthor Commented:
Thanks for that. I tried date and got 'invalid date format message'. Will look at ADO.
0
 
Ephraim WangoyaCommented:
Try this as well

Query1.ParamByName('SELDATE').AsSqlTimeStamp := DateTimeToSQLTimeStamp(DateTimePicker1.Date);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ClaytonGlassAuthor Commented:
Thanks ewangoya but get a pascal error  - undeclared identifier. AM using BDS2006 if that helps.
0
 
Sinisa VukCommented:
Try
Query1.ParamByName('SELDATE').AsDatetime := Trunc(DateTimePicker1.Date); 

Open in new window

0
 
Geert GruwezOracle dbaCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
ClaytonGlassAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now