Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting DateTime difference in OrientDB

I have the following Carts table schema of orientDB. All I wanted to do is to select those records where

(CurrentTime - timeStamp) >= expiration

Table Schema

I had also tried to achive my goal thorugh converting to unix timestamp and tried following queries

SELECT * FROM Carts WHERE eval("('+new Date().getTime()+' timeStamp.asLong())/1000") >= expiration

And also by following technique but when :parameter is passed in eval funtion it convert it into '?' and don't return required data.

db.query(
        'SELECT eval("'+new Date().getTime()+' - timeStamp.asLong()") as DIFF, :nowTimeStamp as NOW, timeStamp.asLong() as THEN FROM Carts ',
        {
            params: {
                nowTimeStamp: new Date().getTime()
            }
        }).then(callback);
like image 513
Arham Ali Qureshi Avatar asked Nov 28 '25 17:11

Arham Ali Qureshi


1 Answers

Try this query:

SELECT * FROM Carts WHERE eval("SYSDATE().asLong() / 1000 - timeStamp.asLong() / 1000") >= expiration

Hope it helps.

like image 124
Oleksandr Gubchenko Avatar answered Nov 30 '25 08:11

Oleksandr Gubchenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!