Subject Re: [IBO] TIBOQuery modify Order affects Params
Author teamtlas
Hey thanks for the explanation.

It's encouraging because the implication is that there is no need to
change my application code - phew! (Once the problem in IBO is fixed
of course!).

In the meatime, if I do a temporary modification the
EncodeStringToDateTime function in IB_Utils I assume everything will
be OK?

Regards,

Mark H (teamtlas)


--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:

> Jason and Mark,
>
> The problem occurs when the InternalDataset is assigning the date in
the
> AsDateTime call in IBA_Statement.IMP, line 2216. It calls the
> EncodeStringToDateTime() function in IB_Utils (which I **swear**
Jason that
> you fixed two years ago when we went through this together...)
>
> This function is "blind" to all date string formats except
mm/dd/yyyy.
> Somewhere I have an alternative pair of decode/encode date functions
that
> work for NZ, Australia and the rest of the world.
>
> Anyway, glad (Jason) that you're looking at this now.
>
> function EncodeStringToDateTime( AValue: string ): TDateTime;
> var
> Day, Month, Year, Hour, Minute, Second, MSec: word;
> tmpStr: string;
> begin
> if AValue = '12/30/1899 00:00' then
> Result := 0
> else
> try
> Year := StrToInt( Copy(AValue,1,4) );
> Month := StrToInt( Copy(AValue,6,2) );
> Day := StrToInt( Copy(AValue,9,2) );
> Hour := StrToInt( Copy(AValue,12,2) );
> Minute := StrToInt( Copy(AValue,15,2) );
> Second := StrToInt( Copy(AValue,18,2) );
> // Ensuring that we cope if some accidently sends us a value
with
> // less than the require number of digits...
> tmpStr := Trim(Copy(AValue,21,4)) + '0000';
>
> But we don't cope with Windows-localised output from StrToDate!!
>
> // Read only 3 digits to get "milli" seconds, not the full 4
digits
> // which are available from the string to give 10000ths of a
second
> // (This is a truncate rather than a round, but it should be
adequate)
> MSec := StrToInt( Copy(tmpStr,1,3) );
> Result := EncodeDate( Year, Month, Day );
> if Result >= 0 then
> Result := Result + EncodeTime( Hour, Minute, Second, MSec )
> else
> Result := Result - EncodeTime( Hour, Minute, Second, MSec )
;
> except
> Result := StrToDateTime( AValue );
> end;
> end;
>
> Mark, the reason it doesn't occur on your initial run is that your
code
> isn't reading the edit box initially. It's only when the statement
gets
> invalidated by the new statement string that the date parameter gets
stuffed.
>
> Helen