Reputation: 53
I have two dates ,I want to get days between those two dates using SPARQL
I have refered SPARQL Calculating the difference between two date
but using above link I got only year ,but I want actual days between two date Please give me suggestion on same
thanks in advance.
Upvotes: 3
Views: 917
Reputation: 1294
If you subtract dates, your answer is given in seconds. So you need divide the result by a number to specify the result in days: (3600 (number of seconds in an hour) times 24 (number of hours in a day). (If you would also multiply by 365, you would get the answer in years.)
So based on the reference you gave:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?age where {
bind( "1732-02-28"^^<http://www.w3.org/2001/XMLSchema#date> as ?death )
bind( "1732-02-22"^^<http://www.w3.org/2001/XMLSchema#date> as ?birth )
bind( (?death-?birth)/(3600*24) as ?age )
}
Resulting in the age in days:
"6"^^<http://www.w3.org/2001/XMLSchema#integer>
Upvotes: 2