Nesler, Thomas J wrote:
> Date fields have always been a puzzle to me.  Basically they are float
> type fields but Delphi doesn't handle them that way when it comes to
> comparisons with constants.

Yes it does.

> I am doing a report where I look at a date field.  If the field has a
> date then I show 'Yes' in the report line otherwise I show a 'No'.
> Since it is a numeric field, I thought I would just do a compare with
> zero, like this:
> 
> If NXQuery1.Fieldbyname('ActShipDate').Value > 0.0 then S := '  Yes   '
>                                                     else S := '   No
> ';

What does that code have to do with dates? There are no TDateTime- or 
TDate-typed expressions in that statement. I see one expression of type 
Variant and one of type Double.

If the field's value is zero, then there is still a values there. When 
interpreted as a TDateTime, it represents 30 December 1899.

If there is no date in the field, then the field's value is probably 
null. I don't know what it means to read the Value property of a field 
that has no value. Try using the IsNull property.

> When I exccute this line I get a runtime error 'invalid type
> conversion'.  What can I do to overcome this problem?

Start to overcome it by refraining from using Variants. Try the 
AsDateTime property instead of the Value property, so everyone 
(including the compiler) knows exactly what kind of value you're 
expecting to use.

-- 
Rob


-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to