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

**URL:** <https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284>\
**Category:** Bug\
**Created:** [September 11, 2018, 7:32am UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284 "2018-09-11T07:32:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![xgfd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/xgfd/32/302_2.png) [@xgfd](https://community.stardog.com/u/xgfd)\
**Post date:** [September 11, 2018, 7:32am UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/1 "2018-09-11T07:32:49Z")

</div>

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)
}
```

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [September 11, 2018, 9:53am UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/2 "2018-09-11T09:53:04Z")

</div>

> [@xgfd](#):
>
> but if we replace ?ts with "2018-09-10T11:12:19.417"^^xsd:dateTime no result is returned.

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

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [September 11, 2018, 11:41am UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/3 "2018-09-11T11:41:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xgfd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/xgfd/32/302_2.png) [@xgfd](https://community.stardog.com/u/xgfd)\
**Post date:** [September 11, 2018, 12:05pm UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/4 "2018-09-11T12:05:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xgfd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/xgfd/32/302_2.png) [@xgfd](https://community.stardog.com/u/xgfd)\
**Post date:** [September 11, 2018, 12:06pm UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/5 "2018-09-11T12:06:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xgfd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/xgfd/32/302_2.png) [@xgfd](https://community.stardog.com/u/xgfd)\
**Post date:** [September 11, 2018, 12:08pm UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/6 "2018-09-11T12:08:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [September 13, 2018, 7:09pm UTC](https://community.stardog.com/t/certain-datetime-doesnt-match-in-a-triple-pattern-but-does-in-a-filter/1284/7 "2018-09-13T19:09:36Z")

</div>

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?

```auto
✔ 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

```
