Subject | Re: [IBO] Type conversion |
---|---|
Author | Helen Borrie |
Post date | 2001-01-29T03:11:24Z |
At 01:44 PM 29-01-01 +1100, you wrote:
*only* cast Timestamp from one of the valid InterBase date literals. :(
it. Not pretty though.
Another idea:
Could you bring in item.startdate as a ftDateTime and log.offset as an
integer calculated by multiplying the stored value by the precision, and
use a ftCalculatedField type for your output field by putting code into
OnCalcFields to
1) subtract log.offset from item.startdate (you can do this with a TDateTime)
2) divide the result by the precision
3) multiply that by 2
4) cast the result into a DateTime which you assign to a client-side
calculated field (i.e. traditional Delphi-style calc field)
H.
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>I tried this but the problem is that the cast to Timestamp requires a stringYes, yer right. It's discussed in Chap. 7 of the EmbedSQL manual - you can
>(I think) and not a double.
*only* cast Timestamp from one of the valid InterBase date literals. :(
>The SQL statement contains:Yup, that's consistent with the documentation.
>
>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 indicateIf you're converting to a date literal string, this looks like a way to do
>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.
it. Not pretty though.
Another idea:
Could you bring in item.startdate as a ftDateTime and log.offset as an
integer calculated by multiplying the stored value by the precision, and
use a ftCalculatedField type for your output field by putting code into
OnCalcFields to
1) subtract log.offset from item.startdate (you can do this with a TDateTime)
2) divide the result by the precision
3) multiply that by 2
4) cast the result into a DateTime which you assign to a client-side
calculated field (i.e. traditional Delphi-style calc field)
H.
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________