SPARQL:
prefix sosa: <http://www.w3.org/ns/sosa/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?f ?vv1 (year(?t) as ?t1) ?t
WHERE {
  ?s a sosa:Observation .
  ?s sosa:hasFeatureOfInterest ?f .
  ?s sosa:resultTime ?t .
  bind(YEAR(?t) as ?vv1)
}

Where the data is e.g.:
prefix sosa: <http://www.w3.org/ns/sosa/> .
prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
prefix ex: <http://www.example.org/> .
ex:beachSample-2014-0 a sosa:Observation ;
sosa:hasFeatureOfInterest "CT992639"^^xsd:string ;
sosa:resultTime "2014-05-27T00:00:00Z"^^xsd:dateTime .

Loaded as follows:
./apache-jena-4.2.0/bin/tdbloader2 --loc=/A ./tmp.n3

And queried with (where q1.rq contains the SPARQL query above):
./apache-jena-4.2.0/bin/tdbquery --loc=/A --query=./q1.rq

This produces the following result:
-------------------------------------------------
| f          | vv1 | t1 | t                     |
=================================================
| "NY635615" |     |    | "2014-06-30 00:00:00" |
| "NY635615" |     |    | "2014-06-10 00:00:00" |

With the expected (hopeful) behavior being an output like this (which is
not the actual query result):
-----------------------------------------------------
| f          | vv1  | t1   | t                      |
=====================================================
| "NY635615" | 2014 | 2014 | "2014-06-30T00:00:00Z" |
| "NY635615" | 2014 | 2014 | "2014-06-10T00:00:00Z" |

Columns *vv1* and *t1* are both attempts to get the year value to appear in
the query result, without success. And column *t* is simply showing the
data being held as sosa:resultTime, where I would assume it would be
formatted as an XSD:dateTime value but instead is appearing a little
differently?

Any help is much appreciated!

-- 
PhD Student in Computer Science (2018-)
University of Illinois at Chicago

Reply via email to