Subject RE: [IBO] Date format issue
Author Claudio Valderrama C.
> -----Original Message-----
> From: Jay [mailto:johannes@...]
> Sent: Viernes 16 de Febrero de 2001 0:56
>
> Thank you Hellen and Jason for your input. Jason's hint solved the
> problem to some degree.
>
> The most confusing part, however, was that
> StoredProc.ParamByName('A_DATE').AsString accepts date formats as
> defined by a machines regional settings. 'AsDate' solved the problem
> here.
>
> In contrast, OnPrepareSQL must have a date format which interbase
> supports. 'get_IBDateLiteral' in 'IB_Parse.pas' did the trick in that
> instance.

This is not a limitation of IBO, but a misunderstanding on how the work is
done against a relational database engine.

When you use parameters, IBO doesn't replace the parameters by literal
strings to create a full literal query string. Neither does the BDE.
Instead, the parameterized query is sent to the server and prepared. Later,
the parameters are passed to the engine through API calls in binary formats
that are set and retrieved through known C structures, for example, the "tm"
structure in C. When you call ParamByName and assign the value, if you use
AsString, it's converted by Delphi routines in binary format, where it will
be passed as a parameter to IB. If you don't want to get caught by regional
settings, use
ParamByName(name).AsDate := EncodeDate(...);

When you write code to the OnPrepare event, you are creating the SQL
property itself, not building parameterized query. Therefore, you must
ensure that the literal string being assembled can be parsed by IB date
routines. Here you should write in regional-neutral format. This is the
reason Jason created the get_IBDateLiteral function.

C.