Search code examples
sqldatabaseorientdb

how to add days in orient db


How do we add days to dates in Orient db?

select sysdate()+1 from safetyplan;

It is giving same output as sysdate(). 1 is not getting added. Can you help me, please?


Solution

  • According to Orientdb doc 2.2:

    sysdate() returns the current date time. If executed with no parameters, it returns a Date object, otherwise a string with the requested format/timezone.

    So one possible way is to convert date object to long using .asLong() method of date object.Then do the necessary addition.Convert it back to date using .asDate() method.

    Example:To get a day added to current day use:

    select sum(sysdate().asLong(),86400000).asDate() from safetyplan;
    

    Note:we are adding in milliseconds and 1 day=1000*60*60*24 milliseconds

    NB:Thought that this answers may help someone and sorry for answering my own question.