Subject | Re: [firebird-support] Firebird 1.5 & DIALECT 3 and 'now' |
---|---|
Author | Helen Borrie |
Post date | 2008-02-14T22:32:22Z |
At 07:39 AM 15/02/2008, Aage Johansen wrote:
Explanation: in dialect 1, integer/integer returns a double precision number whereas in dialect 3, it returns an integer.
select * from USER_SESSION
WHERE (cast ('now' as timestamp) - LastPageTime) > (1.0000/60);
Apply as much scale (within the limits) as you need to get a meaningful answer. This is not as obvious as it might seem, so make sure your expression isn't going to resolve to an (undetected) different result from what you expect.
(Timestamp - <anything valid>) gives a decimal(18,9) result in days, not minutes or seconds.
Do you really want to test for an interval greater than a sixtieth of a day?
./heLen
>Helen Borrie wrote:Oops, yes, there are trees in the forest!
> >> ...
> >> How can I make my query working under Dialect 3?
> >
> > select * from USER_SESSION
> > WHERE (cast ('now' as timestamp) - LastPageTime) > (1/60);
> >
> > or
> >
> > select * from USER_SESSION
> > WHERE (CURRENT_TIMESTAMP - LastPageTime) > (1/60);
> >
>
>
>Note that (1/60) will evaluate to 0.
Explanation: in dialect 1, integer/integer returns a double precision number whereas in dialect 3, it returns an integer.
select * from USER_SESSION
WHERE (cast ('now' as timestamp) - LastPageTime) > (1.0000/60);
Apply as much scale (within the limits) as you need to get a meaningful answer. This is not as obvious as it might seem, so make sure your expression isn't going to resolve to an (undetected) different result from what you expect.
(Timestamp - <anything valid>) gives a decimal(18,9) result in days, not minutes or seconds.
Do you really want to test for an interval greater than a sixtieth of a day?
./heLen