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

Member

by brandy , in category: Third Party Scripts , 4 months 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 , 4 months 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.

Related Threads:

How to group datetime into intervals of 3 hours in mysql?
How to group time column into 5 second intervals and count rows using presto?
How to get a max values in a query sparql?
How to get start of day and end of day in moment.js?
How to display the time of day with moment.js?
How to add an odd day to a time in php?