How to show "2022-09-12T00:00:01"^^xsd:dateTime only as 2022-09-12 or at least without ^^xsd:dateTime in my SPARQL results?

Viewed 20

How to show "2022-09-12T00:00:01"^^xsd:dateTime only as 2022-09-12 or at least without ^^xsd:dateTime in my SPARQL results?

1 Answers

To do this in the query:

If ?variable is "2022-09-12T00:00:01"^^xsd:dateTime you can get just the string part (the lexical form) with str(?variable).

If you want to loose the time part, cast to an xsd:date i.e. xsd:date(?variable)

Combined: str(xsd:date(?variable)).

An alternative is to use accessors YEAR, MONTH and DAY (they return integers) to get the parts you want and make a string.

Related