Subject Re: [ib-support] days from January the 1st
Author Helen Borrie
At 10:56 AM 02-03-02 +0100, you wrote:
>inside a SP, I need to compute the number of days that have elapsed since
>January the 1st of the current year up to a given date (also of the current
>year).
>
>For now, I have been able to write
>
> gg=cast(:d_mov-'2002-01-01' as integer);
>
>but the bluff won't last long... :)
>
>Any hint ?

It's not far out:

gg = :d_mov - cast('2002-01-01' as date);

If :d_mov is a timestamp you'll have to do this:

gg = cast(:d_mov as date) - cast('2002-01-01' as date);

cheers,
Helen

All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________