Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Timestamp difference
Tue, Aug 13 2019 5:52 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Hi, i try to get following sql work but have a problem understanding the error message:

select dtstamp, current_timestamp, current_timestamp-dtstamp,
cast(current_timestamp-dtstamp as interval minute),
cast((current_timestamp-dtstamp) as integer)/60 notworking
from mytable

- the dtstamp field is a timestamp

Exception: ElevateDB Error #700 An error was found in the statement at line 3 and column 7 (Expected Char, VarChar, Byte, VarByte, Boolean, SmallInt, Integer, BigInt, Float, Decimal, Interval Year, Interval Day, Interval Hour, Interval Minute, Interval Second, or Interval MSecond expression but instead found (CURRENT_TIMESTAMP() - "dtstamp"))
Yusuf Zorlu
MicrotronX
Tue, Aug 13 2019 6:02 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

I see that this works, but is it the "correct" way?

cast(abs(cast(current_timestamp-dtstamp as interval minute )) as integer)
Yusuf Zorlu
MicrotronX
Tue, Aug 13 2019 9:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf


If it works its a correct way Smiley

You've just encountered the fact that unlike DBISAM date, time & timestamp are no longer floats - they now have their own type and date/time arithmetic is a bit more complex than it used to be.

The only bit of your code I would question is ABS - if dtstamp is guaranteed to always be less than current_timestamp then it shouldn't be needed

Roy Lambert
Image