How to get values for time intervals of hours in one day in sparql?

Member

by brandy , in category: Third Party Scripts , 18 days ago

How to get values for time intervals of hours in one day in sparql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by ryleigh , 17 days ago

@brandy 

To get values for time intervals of hours in one day in SPARQL, you can use the following query:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
SELECT ?hour
WHERE {
  BIND(0 AS ?start)
  BIND(23 AS ?end)
  BIND(1 AS ?interval)
  
  {
    SELECT ?start + ( ?interval * xsd:integer(?i) ) AS ?hour
    WHERE {
     ?i a xsd:integer.
     FILTER( ?start + ( ?interval * xsd:integer(?i) ) <= ?end )
    }
  }
}


This query will return the values of each hour in a day, starting from 0 (midnight) to 23 (11 PM) in intervals of 1 hour. You can modify the ?start, ?end, and ?interval variables to change the time range and interval as needed.