Calculating interval

hi, @MichelDiz

How to calculate the interval between the date and 2020-05-21?
I want to run code like this, but it’s error…

math(since(date) - since(2020-05-21))

since returns the number of seconds from the time specified as a float. Are you sure that’s what you want to do?

if you want to do the number of seconds since 2020-05-21, you could just do since(2020-05-21)

Although I am not exactly sure what you want to do

Both dates has to be present as predicates for the following to work. I could not get it to work by making one of them as variables (I am assuming that was perhaps your intention).

With this mutation:

  _:a <cdate> "2020-05-21" .
  _:a <bdate> "2019-05-21" .

this query returns results as below

query myDemoQuery() {

  films(func: has(bdate)) {
    pastDate as bdate
    futureDate as cdate
    futureSeconds as math(since(futureDate)    )
    pastSeconds as math(since(pastDate)    )  
    difference: math(pastSeconds - futureSeconds   )


  "data": {
    "films": [
        "bdate": "2019-05-21T00:00:00Z",
        "cdate": "2020-05-21T00:00:00Z",
        "val(futureSeconds)": 11007887.911656,
        "val(pastSeconds)": 42630287.911659,
        "difference": 31622400.000003