Subject Re: [IBO] Type conversion
Author shanevan@optushome.com.au
I tried this but the problem is that the cast to Timestamp requires a string
(I think) and not a double.

The SQL statement contains:

cast(cast (item.startdate as float) + cast(log.offset as float) * 2.0 as
timestamp)

This will produce an error like:
Overflow error during type conversion. Conversion error from string
"9.9999999999 ."

Using a TDBChart gets around the problem because it has a flag to indicate
the field is a date and so the graph actually displays the dates. The
TDBGrid is the issue where I see the floating point values and not the date.
I have used the SetFieldType command but it has had no impact. As far as I
can tell there is no means to specify the field type within the TDBGrid, it
is set by IB or IBObjects.

I call the SetFieldType after I make the query active. If I do it before
then the field name does not exist. I don't know if this impacts upon
anything.

Also the above SQL will not operate on my PC because the time/date format
results in an overflow error. In my code I actually convert the startdate in
Delphi and dynamically create the SQL.

TIA
Shane


----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <IBObjects@yahoogroups.com>
Sent: Monday, January 29, 2001 12:15 PM
Subject: Re: [IBO] Type conversion


> At 09:58 AM 29-01-01 +1100, you wrote:
> >
> >I am using an IBOQuery to populate a TDBGrid with data (as well as some
> >other controls that are not reproduced in IBObjects).
> >
> >The problem I have is that even though I can covert the type to a
> >date/time in the other controls, I can not display the values as a
> >time/date in the grid. The value is actually derived from a calculation
> >and is a double.
> >
> >The SetFieldType is meant to do it for me but I noticed that it is not
> >mentioned in the help file. Is it not supported in IBObjects and is there
> >another technique I should be using?
>
> Cast it as the appropriate type when you do the calculation in your SQL
> statement, e.g.
>
> select FieldA, FieldB, CAST(SomeValidExpression as Timestamp) as CalcDate,
> more fields
> from ATable
>
> hth
>
> Helen
>
> All for Open and Open for All
> InterBase Developer Initiative ยท http://www.interbase2000.org
> _______________________________________________________
>
>
>
>