@shyann
To compare date values in SPARQL, you can use the functions YEAR()
or xsd:year
to extract the year from the date values and then compare them with specific years. Here is an example query that demonstrates how to compare date values with year values in SPARQL:
1 2 3 4 5 6 7 8 |
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?dateValue WHERE { ?dateValue a rdf:type <http://example.org/DateEntity> ; <http://example.org/dateProperty> ?date . FILTER(YEAR(?date) = 2022) } |
In this query, we are fetching all date values (?dateValue
) that have a date property (<http://example.org/dateProperty>
) with the year equal to 2022. The YEAR()
function extracts the year from the date value for comparison.
Replace <http://example.org/DateEntity>
and <http://example.org/dateProperty>
with your actual ontology URIs and properties. Adjust the comparison year (2022 in this example) to the specific year that you want to compare with.
By using the YEAR()
function and filtering by the year values, you can effectively compare date values with specific years in SPARQL.