Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Obtaining records within a certain timeframe
Tue, Jan 15 2019 9:53 PMPermanent Link

Adam H.

Hi,

I have a table, that includes a Timestamp field (for the example let's call the field "DateTime").

What I wish to be able to do is get a list of entries in the table where the entry in the TimeStamp field is more than 30minutes old, but I'm unsure of how to do this in SQL.

I thought of doing something such as

Select *
From MyTable
where (DateTime < current_timestamp - (1/48))

(24hrs in a day, or 48 'half hours' in a day)...

But I get an error. Even if I change it to the decimal equivalent of:

Select *
From MyTable
where (DateTime < current_timestamp - (0.0208333))

But I still get DBISAM Engine Error #11949 - Expected Null, SmallInt, Word, AutoInc, Integer, LargeInt, Date, Time or Timestamp expression but instead found 0.0208333 in Select SQL.


I've also tried casting the timestamp fields as a float field:

Select *
From MyTable
where (Cast(DateTime as Numeric) < Cast(Current_TimeStamp as Numeric) - 0.0208333)

... but this fails as well...

Can anyone please suggest what I should be using in order to view only the records that are more than 30 minutes old without having to hardcode in an actual time stamp?

Thanks

Adam
Tue, Jan 15 2019 10:25 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Adam,

SELECT * FROM Tbl WHERE DateTime < CURRENT_TIMESTAMP - 30*60*1000

It's 30 minutes * 60 Seconds * 1000 miliseconds

--
Fernando Dias
[Team Elevate]
Tue, Feb 5 2019 12:37 AMPermanent Link

Adam H.

Hi Fernando,

Thanks for the example. I can use that - cheers!

Adam.
Image