Reputation: 81
I dont really find anything online , that is why I'm asking here. I have the following query :
"return all the people that prefer to depart in the morning"
myns is my PREFIX of my ontology in Protedge. Here is what I wrote so far :
SELECT ?person
WHERE {
?person myns:bookTicket ?ticket.
?ticket myns:hasFligth ?fligth.
?fligth myns:hasDepartureTime ?time.
FILTER ( how to return ?time that depart in the morning so < 1pm )
}
Here myns:hasDepartureTime returns an xsd:dateTime type (E.G "2022-05-04T22:00:00"). I know how to filter by Date but I dont really know how to extract the time so I can filter it by Time. I need to return all the fligths that depart in the morning so I can accomplish my goal. Because no matter which time I use , the FILTER will always look at the day first, and I dont care about which day the fligth departs but only its time.
Upvotes: 0
Views: 450
Reputation: 85913
but I dont really know how to extract the time so I can filter it by Time.
As UninformedUser mentioned in a comment:
use hours and minutes functions on the xsd:dateTime literal in your filter
For example:
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select ?dt {
values ?dt {
"2022-07-18T10:06:41.756+00:00"^^xsd:dateTime
"2022-07-18T17:06:41.756+00:00"^^xsd:dateTime
"2022-07-18T14:06:41.756+00:00"^^xsd:dateTime
"2022-07-18T08:06:41.756+00:00"^^xsd:dateTime
}
filter ( hours(?dt) < 13 )
}
Upvotes: 1