Certain datetime doesn't match in a triple pattern but does in a Filter

We have the following query

SELECT
  *
WHERE {
  ?risk a risk:SettledRisk .
  ?risk meta:hasTimestamp ?ts .
}

which gives

?ts = 2018-08-31T11:12:18.887

but if we replace ?ts with "2018-08-31T11:12:18.887"^^xsd:dateTime no result is returned.

SELECT
  *
WHERE {
  ?risk a risk:SettledRisk .
  ?risk meta:hasTimestamp "2018-08-31T11:12:18.887"^^xsd:dateTime .
}

If we put the timestamp in a filter it works

SELECT
  *
 WHERE {
  ?risk a risk:SettledRisk .
  ?risk meta:hasTimestamp ?ts .
  FILTER (?ts = “2018-08-31T11:12:18.887”^^xsd:dateTime)
}

Did you mean to use a different date than the one returned in the previous query?

You also have ?risk a risk:SettledRisk in the non-working query, and ?risk a risk:UnsettledRisk in the one with the filter.

I used a date that’s returned by the first query. Actually all other dates returned by the first query worked when I replaced ?ts with them.

Sorry, my bad. They should be the same. The only difference is with ?ts and “2018-08-31T11:12:18.887”^^xsd:dateTime. Let me try editing my question.

I edited my question to have consist values in all queries.

With a Stardog 5.3.3 instance, I am unable to reproduce this error. If you run your initial query (the one that produces the timestamp value), does it show the value as an xsd:dateTime?

✔ stephen:stardog [ bug/5864 | ✚ 1 …1 ⚑ 2 ] ➭ stardog query myDb "select ?p ?o {?s ?p ?o . bind(datatype(?o) as ?t) filter(?t = xsd:dateTime)} limit 1"
+---------------------------------+--------------------------------------------------+
|                p                |                        o                         |
+---------------------------------+--------------------------------------------------+
| http://purl.org/dc/terms/issued | "2017-07-20T22:26:02.631805+02:00"^^xsd:dateTime |
+---------------------------------+--------------------------------------------------+

✘ stephen:stardog [ bug/5864 | ✚ 1 …1 ⚑ 2 ] ➭ stardog query myDb "select * { ?s <http://purl.org/dc/terms/issued> '2017-07-20T22:26:02.631805+02:00'^^xsd:dateTime }"
+-------------------------------+
|               s               |
+-------------------------------+
| http://stardog.com/foobar/42/ |
+-------------------------------+

Query returned 1 results in 00:00:00.183
✔ stephen:stardog [ bug/5864 | ✚ 1 …1 ⚑ 2 ] ➭ stardog query myDb "select * { ?s <http://purl.org/dc/terms/issued> ?ts . filter(?ts = '2017-07-20T22:26:02.631805+02:00'^^xsd:dateTime) }"
+-------------------------------+--------------------------------------------------+
|               s               |                        ts                        |
+-------------------------------+--------------------------------------------------+
| http://stardog.com/foobar/42/ | "2017-07-20T22:26:02.631805+02:00"^^xsd:dateTime |
+-------------------------------+--------------------------------------------------+

Query returned 1 results in 00:00:00.179