Subject | Re: [IBO] TIBOQuery modify Order affects Params |
---|---|
Author | Helen Borrie |
Post date | 2003-10-30T04:06:03Z |
At 02:48 AM 30/10/2003 +0000, you wrote:
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
>--- In IBObjects@yahoogroups.com, "Jason Wharton" <jwharton@i...>Jason and Mark,
>wrote:
> > I would like a sample of this problem with a database so I can
>examine this
> > and resolve whatever is needed. I am currently dealing with TParams
>and
> > tidying things up so your timing is good.
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