1 year ago
#316064
JAT86
Format dates based on date precision
I am using Wikidata Query Service to get the dates of population of some places. The output gives a raw result in the format 2010-01-01T00:00:00Z
(as an example). I have also retrieved the date precision of each date. The query results display the dates in 1 January 2010
format, but upon downloading the csv or tsv file, the dates are still displayed in the raw format 2010-01-01T00:00:00Z
.
I would want to display the following dates based on their date precision:
if (date precision = 11
), display 1 January 2010
if (date precision = 10
), display January 2010
if (date precision = 9
), display 2010
otherwise, just display the raw date
How can I do this, and how can I force the downloaded csv or tsv file to display the formatted dates?
SELECT DISTINCT
?place
?placeLabel
?population
?populationDate
?populationDatePrecision
WHERE {
?place p:P31 ?instanceOf.
?instanceOf ps:P31/wdt:279* wd:Q134390.
OPTIONAL {
?place p:P1082 ?pop_statement .
?pop_statement ps:P1082 ?population;
pqv:P585 [
wikibase:timePrecision ?populationDatePrecision;
wikibase:timeValue ?populationDate ].
}
minus { ?instanceOf pq:P582 ?endTime. }
service wikibase:label { bd:serviceParam wikibase:language "en". }
} ORDER BY ?placeLabel
sparql
wikidata
wikidata-query-service
0 Answers
Your Answer