Solved

Passing Date To Stored procedure for Delphi application as INPUT paramater...

Posted on 2006-07-08
3
378 Views
Last Modified: 2010-04-05
Hi

I am calling interbase/firebird  stored procedures from my delhi apllication to post entries to tables, OR to lookup data for reports.

MY problem is as follows when I SOMETIMES call a stored procedure and pass a date as input paramater then my delphi application falls over.
I get invalid date ("20/05/2005") or other invalid date errors.
My stored procedure recieve a Date Type Varaiable..


WHAT is the correct way to call a stored procedure and to pass a DATE to a stored procedure.
I am currently doing the following..
sQry := Format('execute procedure  SP_GetEmployees "%s",  //The procedure recieve one Date variable as input paramter
           [FormatDateTime('yyyy/mm/dd',Now()));

Please I am not sure which is the correct way to pass a Date, and which is the safest way without delphi falls over.

Thank you
henry
0
Comment
Question by:henryreynolds
3 Comments
 
LVL 13

Expert Comment

by:BlackTigerX
Comment Utility
that depends on how the sql server is configured, but I think you can use this format

YYYY-MM-DD
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 500 total points
Comment Utility
The best way would be to use parameters (they start with : ), you then set the parameter by using the .AsDateTime method
eg.
ibsql1.sql.text := 'execute procedure SP_GetEmployees(:ParamSomeDate)';
ibsql1.ParamByName('ParamSomeDate').AsDateTime := Now; // or your date variable
ibslq1.ExecQuery;

or you could always format it as dd-mmm-yyyy which cannot be misunderstood

e.g.
execute procedure SP_GetEmployees('01-Jan-2006')
or
ibsql1.sql.text := 'execute procedure SP_GetEmployees(' + FormatDateTime('dd"-"mmm"-"yyyy', SomeDate) + ')';
0
 
LVL 5

Expert Comment

by:Scay7
Comment Utility
Sorry for this :

TheRealLoki --->
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21881726.html

Please reply, you havent replied in almost a month...

Peace Scay7
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

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

10 Experts available now in Live!

Get 1:1 Help Now