<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>I. Smessaert);</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>It's About Time: Time Functions for Comparing Partial and Floating Time Literals in SPARQL</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ieben Smessaert</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Julián Rojas Meléndez</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pieter Colpaert</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="editor">
          <string-name>SPARQL, Time Literals, Extension Functions, Partial Times, Floating Times</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IDLab, Department of Electronics and Information Systems, Ghent University - imec</institution>
          ,
          <addr-line>Ghent</addr-line>
          ,
          <country country="BE">Belgium</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2025</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Working with temporal data on the Semantic Web remains challenging due to SPARQL's limited support for comparing time literals of different data types and handling floating times without explicit time zones. These issues are especially problematic when dealing with partial time literals (such as xsd:date, xsd:gYearMonth, or xsd:gYear) and floating times, both of which are common in real-world knowledge graphs like Wikidata. To showcase the relevance and urgency of the problem, we gathered and reviewed existing discussions, specifications, draft proposals, and examples from deployed knowledge graphs, providing a consolidated starting point for further community dialogue. We then proposed a solution in the form of a set of SPARQL extension functions-Time Functions-designed to reinterpret time literals as time intervals, enabling consistent and type-agnostic temporal comparisons. These functions are formally described using the Function Ontology (FnO), and implemented in the Comunica query engine, with a publicly available demo application that allows users to interactively explore and test the functions. The demo includes curated example queries that highlight both the limitations of existing SPARQL behavior and how the Time Functions enable more accurate filtering and sorting of temporal data. In addition to providing a technical proposal, we advocate for improved temporal data publishing practices, urging data providers to use accurate data types and explicit time zones to support reliable temporal reasoning in the openworld context of RDF.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>and querying frameworks such as Virtuoso, BlazeGraph, and Comunica return false or empty results in
these cases, even if the date parts of the literals are comparable.</p>
      <p>This issue becomes problematic in large-scale, real-world knowledge graphs like Wikidata, where
users can specify date precision (e.g., year, month, day) when entering temporal data. Its SPARQL end‐
point, however, returns fully qualified xsd:dateTime values without indicating the original precision. For
example, a historical event entered as 27th century BCE may appear as such in the user interface, but is
internally represented and queryable only as "−2650-01-01T00:00:00Z"^^xsd:dateTime. This loss of preci‐
sion in the queryable data undermines temporal reasoning and can produce misleading query results,
such as asserting that this historical event happened in the month of January.</p>
      <p>
        Another critical challenge arises with floating times, which are time literals that lack time zone infor‐
mation. A literal like "2025-08-01T12:00:00"^^xsd:dateTime can be interpreted differently depending on
the context, or may be wrongly adjusted to the user’s local time zone. This ambiguity makes consistent
comparison and sorting unreliable. While the W3C Group Draft Note on Working with Time and
Timezones [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] recommends treating such floating times as UTC by default, this approach is insuffi‐
cient in the open and distributed context of the Semantic Web, where data originates from diverse
sources with potentially different implicit time zone assumptions. As discussed in the GitHub issue re‐
garding implicit time zones in SPARQL1, it is problematic to consider floating times from different
sources as equal because they can represent different time instants and thus have different implicit
time zones.
      </p>
      <p>
        A more robust approach is to treat all temporal literals—particularly floating and partial ones—as
time intervals, bounded by their earliest and latest possible interpretations. For example, a floating
time can be represented by the time interval it could occupy across the full range of legal time zone
offsets (−14:00 to +14:00, as per XML Schema Part 2: Datatypes Second Edition [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]). This perspective
enables meaningful comparison between floating, partial, and fully-qualified time literals by aligning
them to their temporal bounds rather than requiring exact matches.
      </p>
      <p>
        Despite the growing interest in temporal reasoning on knowledge graphs, e.g., in works such as
Soulard et al. 2025 [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], issues around time zones and floating times are rarely addressed explicitly.
Moreover, while enhancement proposals like SEP-00022 improve SPARQL’s handling of date-time
arithmetic, they do not cover cross-type comparison or floating time semantics.
      </p>
      <p>This paper aims to highlight these overlooked issues and present a concrete, extensible solution. We
propose a set of SPARQL extension functions—called Time Functions—that enable comparison across
different temporal data types, interpretation of floating and partial times as intervals, and consistent
and explainable time-based filtering and sorting.</p>
      <p>The remainder of this paper is structured as follows. Section 2 introduces the proposed SPARQL ex‐
tension functions for time handling, along with their formal semantics. Subsequently, Section   3
presents a demo application showcasing how these functions enable richer and more accurate tempo‐
ral queries over RDF data. Finally, Section 4 concludes with a discussion of how Time Functions ad‐
dress the limitations of SPARQL for temporal reasoning, highlights their relevance for future standard‐
ization, and encourages improved temporal data publishing practices.</p>
    </sec>
    <sec id="sec-2">
      <title>2.  Time Functions</title>
      <p>To address the limitations of SPARQL when dealing with temporal data, particularly the inability to
compare partial or floating time literals, we propose a set of SPARQL extension functions called Time
Functions. These functions allow for consistent, meaningful comparison and reasoning over heteroge‐
neous temporal literals by interpreting them as time intervals.</p>
      <p>
        The formal specification and accompanying ontology for these functions are available at https://
w3id.org/time-fn. The ontology uses the namespace https://w3id.org/time-fn# with the recommended
prefix tfn:. This specification defines the semantics of each function and provides an ontology for inte‐
grating time-aware logic into SPARQL queries. The ontology relies on the Function Ontology (FnO) [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]
to formally describe the semantics, inputs, and outputs of each function. FnO provides a reusable and
machine-readable vocabulary for specifying function metadata, well-suited for describing SPARQL ex‐
tension functions. This approach aligns with Semantic Web best practices and mirrors GeoSPARQL’s
extension function set defined using FnO3. By adopting this method, the Time Functions can be consis‐
tently documented, discovered, and potentially reused by other tools and specifications.
      </p>
    </sec>
    <sec id="sec-3">
      <title>2.1. Motivation And Design</title>
      <p>
        Time Functions treats all temporal literals as time intervals, interpreted as the range of time they
could represent based on their earliest and latest possible interpretations. For instance, a literal
"2025-08"^^xsd:gYearMonth spans from August 1st ("2025-08-01T00:00:00-14:00"^^xsd:dateTime) to August
31st ("2025-08-31T23:59:59+14:00"^^xsd:dateTime). As discussed in Section   1, the W3C XML Schema
Recommendation [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] is followed to interpret floating date-time values as intervals that encompass all
possible time zone offsets, using the full ±14:00 hour range, rather than defaulting to a specific time
zone like UTC.
      </p>
      <p>By shifting from point-based to interval-based reasoning, these functions enable meaningful com‐
parisons across data types, handle ambiguities introduced by missing time zones or precision, and
make temporal filtering in SPARQL more reliable and consistent.</p>
    </sec>
    <sec id="sec-4">
      <title>2.2. Overview Of Time Functions</title>
      <p>
        The current Time Functions include five core functions:
• tfn:periodMinInclusive(?timeLiteral): Returns the inclusive lower bound of the time period repre‐
sented by the given temporal literal, as an xsd:dateTime. For example, for "2025-08"^^xsd:gYearMonth,
it returns "2025-08-01T00:00:00.000+14:00"^^xsd:dateTime.
• tfn:periodMaxInclusive(?timeLiteral): Returns the inclusive upper bound of the time period rep‐
resented by the given temporal literal. For the same example, it returns
"2025-08-31T23:59:59.999-14:00"^^xsd:dateTime.
• tfn:periodMinExclusive(?timeLiteral): Returns the exclusive lower bound of the time period. This
is particularly useful for defining open-ended or non-overlapping intervals in filtering logic. For the
same example, it returns "2025-07-31T23:59:59.999+14:00"^^xsd:dateTime.
• tfn:periodMaxExclusive(?timeLiteral): Returns the exclusive upper bound of the time period. For
the same example, it returns "2025-09-01T00:00:00.000-14:00"^^xsd:dateTime.
• tfn:bindDefaultTimezone(?timeLiteral, ?timeZone): For a given floating time literal, this func‐
tion returns a new literal of the same type with the specified time zone bound. If the literal already
includes a time zone, no default time zone needs to be bound to it, and it is returned unchanged. For
the same example, it returns "2025-08+02:00"^^xsd:gYearMonth when bound to the +02:00 time zone.
The function aligns with the approach proposed in Working with Time and Timezones [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], which
recommends interpreting floating times as UTC by default. However, it also supports more flexible,
context-specific interpretations by allowing users to explicitly specify an alternative time zone.
Caution is advised when applying this function across data from heterogeneous sources, as there is
no universally correct default time zone. Nevertheless, the function enables binding a default time
zone retrieved dynamically from the dataset itself. For example, a SERVICE clause may be used to
ensure that the time zone is sourced from the same dataset or endpoint as the time literal, preserv‐
ing consistency within federated queries. An example of such a query is included in the demo appli‐
cation, showcasing how default time zones can be retrieved and applied dynamically based on the
queried data source.
      </p>
    </sec>
    <sec id="sec-5">
      <title>2.3. Use Cases</title>
      <p>The Time Functions are applicable in a wide range of practical scenarios. When comparing dates of
different data types, such as matching an xsd:dateTime with an xsd:date, the functions allow both val‐
ues to be interpreted as intervals and compared accordingly. This is particularly useful in knowledge
graphs where schema constraints are loose and data often lacks uniform temporal granularity.</p>
      <p>Floating time literals pose challenges in distributed and heterogeneous datasets. Without a defined
time zone, their interpretation is ambiguous, leading to incorrect comparisons or missed matches. Time
Functions make it possible to consistently bind a default time zone where appropriate or interpret the
literal as an interval that spans all possible time zones, depending on the application’s needs.</p>
      <p>These functions also support more advanced temporal logic, such as detecting overlaps between
time periods, validating temporal boundaries, and improving sorting behavior. In knowledge graphs
like Wikidata, where date precision is user-defined but not preserved in SPARQL query results, Time
Functions allow users to reconstruct and reason about the intended temporal scope of such data. More
generally, they provide a principled foundation for integrating diverse temporal representations in
SPARQL queries, enabling more accurate and expressive querying of temporal knowledge.
3.  Demo</p>
      <p>To illustrate the practical utility of the Time Functions, we developed an online demo application,
available at https://smessie.github.io/TimeFunctions-SPARQL-Editor/. The application is a lightweight
SPARQL query editor that allows users to experiment interactively with the Time Functions described
in Section 2.</p>
      <p>
        Users can write and execute SPARQL queries, demonstrating how the Time Functions can address
limitations in standard SPARQL when comparing partial or floating time literals. Under the hood, the
demo runs on the Comunica query engine [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], which has been extended4 to support these custom
SPARQL extension functions. The query interface itself is powered by the open-source YASQE editor5,
which offers features such as syntax highlighting and autocompletion.
      </p>
      <p>The application includes example queries that highlight common pitfalls when working with time
literals in SPARQL, as well as how the Time Functions can be used to resolve them. Fig. 1 shows a
screenshot of the demo with a query that compares an xsd:date to an xsd:dateTime. Since SPARQL does
not support comparisons between these types, the query yields no results—even though the date com‐
ponents are logically comparable. In Fig. 2, the same query is rewritten using the Time Functions to
map both literals to their corresponding time intervals. This allows for a meaningful comparison, and
the query returns the expected result.</p>
    </sec>
    <sec id="sec-6">
      <title>4.  Conclusion</title>
      <p>In this paper, we have highlighted an important gap in the current processing of SPARQL queries
dealing with temporal data. This gap includes the inability to directly compare logically comparable
data types such as xsd:date and xsd:dateTime, as well as potential ambiguity when dealing with floating
time literals, especially in federated or heterogeneous data settings. Moreover, current data modeling
practices further complicate temporal reasoning: for instance, Wikidata represents imprecise time peri‐
ods such as “27th century BCE” using a single xsd:dateTime literal (e.g., “-2650-01-01T00:00:00Z”),
thereby flattening a broad time range into a misleading instant. These challenges highlight a broader
need for improved temporal data publishing practices: data should be expressed using accurate data
types that reflect temporal granularity, and time zones should be made explicit wherever possible to
avoid implicit and potentially conflicting assumptions.</p>
      <p>To address these limitations, we proposed a set of SPARQL extension functions, Time Functions,
which reinterpret time literals as time intervals, enabling consistent and type-agnostic comparisons.
These functions support partial dates, floating times, and even cross-type comparisons by interpreting
each time literal as a bounded interval, which can then be compared meaningfully using SPARQL.
Additionally, a function for binding a default time zone enables explicit handling of floating times in a
configurable way. These functions are formally specified using FnO, following established practices
such as those in GeoSPARQL, and are implemented in a demo application using the Comunica query
engine. Our demonstrator provides an interactive environment to explore the functions in action and
illustrates how they resolve common pitfalls in temporal querying.</p>
      <p>While the functions offer an immediate and practical solution, they are also intended to contribute
to the broader discussion around improving temporal reasoning in the upcoming SPARQL 1.2 and be‐
yond. By surfacing the challenges and demonstrating a viable path forward, we hope this work sparks
further standardization efforts and community feedback.</p>
    </sec>
    <sec id="sec-7">
      <title>Endnotes</title>
      <sec id="sec-7-1">
        <title>1. https://github.com/w3c/sparql-query/issues/116 ↩</title>
      </sec>
      <sec id="sec-7-2">
        <title>2. https://github.com/w3c/sparql-dev/blob/main/SEP/SEP-0002/sep-0002.md ↩</title>
        <p>3. https://github.com/opengeospatial/ogc-geosparql/blob/master/vocabularies/functions.ttl ↩
4. https://github.com/smessie/TimeFunctions-SPARQL-Editor/blob/main/src/assets/queryWorker.ts ↩</p>
      </sec>
      <sec id="sec-7-3">
        <title>5. https://docs.triply.cc/yasgui-api/#yasqe ↩</title>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>Declaration On Generative AI</title>
      <p>During the preparation of this work, the author(s) used ChatGPT, DeepL in order to: Grammar and
spelling check, Paraphrase and reword. After using this tool/service, the author(s) reviewed and edited
the content as needed and take(s) full responsibility for the publication’s content.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Cyganiak</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wood</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lanthaler</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>RDF 1.1 Concepts and Abstract Syntax</article-title>
          . https:// www.w3.org/TR/2025/WD-rdf12
          <string-name>
            <surname>-</surname>
          </string-name>
          concepts-20250704/ (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Harris</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seaborne</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>SPARQL 1.1 Query Language</article-title>
          . https://www.w3.org/TR/2013/RECsparql11-query-20130321/#OperatorMapping (
          <year>2013</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Phillips</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Working with Time and Timezones</article-title>
          . https://www.w3.org/TR/timezone/ (
          <year>2024</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>V.</given-names>
            <surname>Biron</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Malhotra</surname>
          </string-name>
          ,
          <string-name>
            <surname>A.</surname>
          </string-name>
          :
          <article-title>XML Schema Part 2: Datatypes Second Edition</article-title>
          . https:// www.w3.org/TR/2004/REC-xmlschema-2-20041028/ (
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Soulard</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          , Saı s̈ Fatiha, Raad, J.:
          <article-title>Explainable Temporal Fact Validation Through Constraints Discovery in Knowledge Graphs</article-title>
          .
          <source>In: European Semantic Web Conference</source>
          . pp.
          <fpage>227</fpage>
          -
          <lpage>244</lpage>
          . Springer (
          <year>2025</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>De</given-names>
            <surname>Meester</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            ,
            <surname>Dimou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Verborgh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            ,
            <surname>Mannens</surname>
          </string-name>
          ,
          <string-name>
            <surname>E.</surname>
          </string-name>
          :
          <article-title>An ontology to semantically declare and describe functions</article-title>
          .
          <source>In: European Semantic Web Conference</source>
          . pp.
          <fpage>46</fpage>
          -
          <lpage>49</lpage>
          . Springer (
          <year>2016</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Taelman</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          , Van Herwegen,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Vander</surname>
          </string-name>
          <string-name>
            <surname>Sande</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Verborgh</surname>
          </string-name>
          , R.:
          <article-title>Comunica: a Modular SPARQL Query Engine for the Web</article-title>
          .
          <source>In: Proceedings of the 17th International Semantic Web Conference</source>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>