Project:SPARQL/examples: Difference between revisions

m
Line 1,086: Line 1,086:
</sparql>
</sparql>


===Value nodes for dates of birth===
===Full values: dates ===


<sparql tryit="1">
<sparql tryit="1">


## to access the timeValue and timePrecision of a date.  
# query for full values to access the timeValue and timePrecision of a date, in this case a date of birth.  
## simple query for a date doesn't differentiate between "1880" and "1 January 1880"; both are returned as 1 January 1880 (and SELECT DISTINCT will collapse them into a single result)
 
## why is a more complex query needed?
## simple value for a date doesn't differentiate between (eg) "1880" and "1 January 1880"; both are returned as 1 January 1880 (and SELECT DISTINCT will collapse them into a single result)
## there are 14 codes for precision from billion years to second. 7: century, 8: decade, 9: year, 10: month, 11: day
## there are 14 codes for precision from billion years to second. 7: century, 8: decade, 9: year, 10: month, 11: day
## NB needs bnpsv: prefix
## NB additional bnpsv: prefix
## https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Value_representation


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 1,106: Line 1,109:
SELECT DISTINCT ?item ?itemLabel ?date ?precision  
SELECT DISTINCT ?item ?itemLabel ?date ?precision  
WHERE {
WHERE {
   ?item bnp:P26  ?statement. # date of birth (these vary in precision)
   ?item bnp:P26  ?statement. # date of birth (precision of these varies quite a bit)
   ?statement bnpsv:P26 ?valueNode.
   ?statement bnpsv:P26 ?valueNode.
   ?valueNode wikibase:timeValue ?date.
   ?valueNode wikibase:timeValue ?date.
579

edits