Subject | Re: [ib-support] DATE and TIMESTAMPS in UDFs?? |
---|---|
Author | Helen Borrie |
Post date | 2001-09-18T12:08:39Z |
At 11:25 AM 18-09-01 +0000, hannes@... wrote:
Your variable 'BDate' should be a timestamp. It looks like a string to me. Try it with :BDate instead (assuming you can get that parameter in there somehow).
The copy of FreeUDFLib source that I have has not had the TimeFncs.pas updated since 13 Jul 1998, so it is possibly going to give wrong results anyway.
This might get the result you want without the UDF call (assuming BDate is a timestamp, not a date type):
select (cast('today' as date) - cast(:BDate as date))/365
as Age_in_years from rdb$database
otherwise
select (current_timestamp - :BDate)/365
as Age_in_years from rdb$database
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>hello IB developers,Hannes,
>is there anything changed with the internal format
>of DATE or TIMESTAMP of 'now' and 'today'?
>
>I tried the f_year('TODAY') function of my old UDF and got
>unbelievable results. the same with Greg Daetz's new FreUDFlib.
>
>Age of persons in
> computed (f_Year('TODAY') - f_year('BDate'));
>returns values like 24548 years :-)
>
>not very many of my customers have really lived then :-)
Your variable 'BDate' should be a timestamp. It looks like a string to me. Try it with :BDate instead (assuming you can get that parameter in there somehow).
The copy of FreeUDFLib source that I have has not had the TimeFncs.pas updated since 13 Jul 1998, so it is possibly going to give wrong results anyway.
This might get the result you want without the UDF call (assuming BDate is a timestamp, not a date type):
select (cast('today' as date) - cast(:BDate as date))/365
as Age_in_years from rdb$database
otherwise
select (current_timestamp - :BDate)/365
as Age_in_years from rdb$database
Cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________