Hi Jeen,

thank you for your help. I assume, that I need to rewrite (extend) the algorithm, because it is constrained for dateTimes that have the same month. Thus, the query will bypass following tuple of dates: 2011-11-31T23:59:59 and 2011-12-01T00:00:01 even the difference is two seconds. But that is OK. The possibility to use custom function is great extension of SESAME, I will surely use it in future.

with regards
Miroslav

On Tue, 22 Nov 2011 11:35:13 +1300, Jeen Broekstra wrote:
On 22/11/11 10:24, Miroslav Líška wrote:
Dear sirs,

I need to subtract two xsd:dateTimes, in order to find individuals that
are created within 48hour interval. For example

?individual1 ex:created ?created1 .
?individual2 ex:created ?created2 .

FILTER (dateDiff(?created1, ?created2)<48)

How it is possible to do it with data stored in OWLIM? I found an issue reported to sesame http://www.openrdf.org/issues/browse/SES-803, hence
it seems that it can not be done so easily.

You can do some things with combinations of the HOURS(), DAY(), etc
functions in SPARQL 1.1.

For example, assuming all your datetimes are in the same timezone,
you could do something like this to get everything in a 48-hour
interval:

 FILTER (?created2 > ?created1)
 FILTER (
    (((DAY(?created2) - DAY(?created1)) * 24)
          + (HOURS(?created2) - HOURS(?created1))
  + (xsd:double(MINUTES(?created2) - MINUTES(?created1)) / 60)
  + (xsd:double(SECONDS(?created2) - SECONDS(?created1)) / 3600)
   ) < 48
   && MONTH(?created2) = MONTH(?created1)
   && YEAR(?created2) = YEAR(?created2)
 )

It's probably technically doable to write a filter that also takes
timezone information into account, but as you can imagine it all
becomes rather complex.

There are some plans to support a set of arithmetic functions
specific for date/time-values in Sesame (hence the issue SES-803 that
you found), but currently it's not yet scheduled for a particular
release.

So let me please ask, whether it is possible to write custom function
that can be used inside sparql query against the OWLIM.

If you want to try this, by all means. Writing custom functions is
fairly easy to do. See [1] for an explanation of what's involved.


Kind regards,

Jeen Broekstra

[1]

http://rivuli-development.com/further-reading/sesame-cookbook/creating-custom-sparql-functions/
_______________________________________________
OWLIM-discussion mailing list
OWLIM-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/owlim-discussion

_______________________________________________
OWLIM-discussion mailing list
OWLIM-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/owlim-discussion

Reply via email to