简体   繁体   中英

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

表格式

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);

Try this query:

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

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM