Subject Re: [ib-support] Cannot calculate value between date and timestamp
Author Helen Borrie
At 04:13 AM 14/05/2003 +0000, you wrote:
>Hi,
>
>I cannot calculate number of days between a date value and a
>timestamp value in the select statement, such as
>
>select current_date-current_timestamp from ...
>
>It shows error:
>
>expression evaluation not supported.
>
>I have to cast them as the same type. Is it a bug or intended to be
>so?
>
>It happens with RC2.

They are different data types. You can subtract a date from another date,
or a timestamp from another timestamp; otherwise explicit casting is
necessary.

select current_timestamp - CAST (current_date as timestamp) as DateDiff from...

This will return a number that is less than one but greater than zero, a
fraction of a day.

select current_date - CAST(current_timestamp as date) as DateDiff from..

will return zero

Your query
select CAST(current_date as timestamp) - current_timestamp from ...
will return a negative number that is greater than -1.

heLen