# Issue with rdf\_assert of date/3

**URL:** <https://swi-prolog.discourse.group/t/issue-with-rdf-assert-of-date-3/2016>\
**Category:** Predicate\
**Tags:** bug\
**Created:** [March 16, 2020, 10:11am UTC](https://swi-prolog.discourse.group/t/issue-with-rdf-assert-of-date-3/2016 "2020-03-16T10:11:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grsjst](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grsjst/32/930_2.png) [@grsjst](https://swi-prolog.discourse.group/u/grsjst)\
**Post date:** [March 16, 2020, 10:11am UTC](https://swi-prolog.discourse.group/t/issue-with-rdf-assert-of-date-3/2016/1 "2020-03-16T10:11:20Z")

</div>

hello,

rdf\_assert of integers (and strings) work as expected:

```prolog
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.24-9-g42b97ff65)
...
?- rdf_assert(a,i,1),rdf_assert(b,i,1).
true.

?- rdf(a,i,N),rdf(b,i,N).
N = 1^^'http://www.w3.org/2001/XMLSchema#integer'.

```

however, for dates this doesn’t seem to work

```prolog
?- rdf_assert(a,d,date(2020,1,1)),rdf_assert(b,d,date(2020,1,1)).
true.

?- rdf(a,d,D),rdf(b,d,D). % <-- I expected this to work
false.

?- rdf(a,d,D1),rdf(b,d,D2).
D1 = D2, D2 = date(2020, 1, 1)^^'http://www.w3.org/2001/XMLSchema#date'.

```

I suppose this is a bug, or am I missing something?

thanks,  
joost

---

<div class="post-metadata">

**Author:** ![grsjst](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grsjst/32/930_2.png) [@grsjst](https://swi-prolog.discourse.group/u/grsjst)\
**Post date:** [March 20, 2020, 4:36pm UTC](https://swi-prolog.discourse.group/t/issue-with-rdf-assert-of-date-3/2016/2 "2020-03-20T16:36:03Z")

</div>

Hello,

Apologies for the self-reply, but I found time to dig a little deeper

given the following TTL

```prolog
@prefix wiki: <https://wiki.fr/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

wiki:r
	wiki:deadline "2020-01-01"^^xsd:date .

```

the following query fails, that I believe should succeed

```prolog
% Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.24-9-g42b97ff65)
?- rdf(wiki:r, P, date(2020, 1, 1)).
false.

```

following

```prolog
rdf(wiki:r, wiki:deadline, D).
D = date(2020, 1, 1)^^'http://www.w3.org/2001/XMLSchema#date'.

```

tracing yields:

```prolog
rdf(wiki:r, wiki:deadline, date(2020, 1, 1)).
   Call: (10) rdf11:rdf('https://wiki.fr/r', 'https://wiki.fr/deadline', date(2020, 1, 1)) ? creep
   Call: (11) rdf11:pre_object(date(2020, 1, 1), _52806) ? skip
   Exit: (11) rdf11:pre_object(date(2020, 1, 1), literal(type('http://www.w3.org/2001/XMLSchema#date', "2020-01-01"))) ? creep
   Call: (11) rdf_db:rdf('https://wiki.fr/r', 'https://wiki.fr/deadline', literal(type('http://www.w3.org/2001/XMLSchema#date', "2020-01-01"))) ? creep
   Fail: (11) rdf_db:rdf('https://wiki.fr/r', 'https://wiki.fr/deadline', literal(type('http://www.w3.org/2001/XMLSchema#date', "2020-01-01"))) ? creep

```

Note the string `"2020-01-01"`

running the query:

```prolog
?- rdf_db:rdf('https://wiki.fr/r', 'https://wiki.fr/deadline', literal(type('http://www.w3.org/2001/XMLSchema#date',D))).
D = '2020-01-01'.

```

returns the date as an atom, which I suppose explains the failure?

Thanks,  
Joost

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 20, 2020, 5:01pm UTC](https://swi-prolog.discourse.group/t/issue-with-rdf-assert-of-date-3/2016/3 "2020-03-20T17:01:48Z")

</div>

> [@grsjst](#):
>
> Apologies for the self-reply, but I found time to dig a little deeper

No need to apologize for diagnosing problems 🙂 Sorry, forgot about this one. With this analysis it was easy, so I pushed a fix.

```
Thanks --- Jan

```
