# xsd:dateTime format

**URL:** <https://community.stardog.com/t/xsd-datetime-format/546>\
**Category:** Support\
**Created:** [September 6, 2017, 10:51pm UTC](https://community.stardog.com/t/xsd-datetime-format/546 "2017-09-06T22:51:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterneorr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/peterneorr/32/31_2.png) [@peterneorr](https://community.stardog.com/u/peterneorr)\
**Post date:** [September 6, 2017, 10:51pm UTC](https://community.stardog.com/t/xsd-datetime-format/546/1 "2017-09-06T22:51:07Z")

</div>

Hello All,

Our java application started recently started barfing when we attempted to insert xsd:dateTime literals formatted like the following:  
`2017-03-02T14:14:23.000-0800`

I noticed that the stardog web console has no problem with the following sparql:

```auto
  select * where {
    bind ("2017-03-02T13:31:59.000-0800"^^xsd:dateTime as ?t1)
    bind ("2017-03-02T13:31:59.000Z"^^xsd:dateTime as ?t2)
    bind ( datatype (?t1) as ?type1)
    bind ( datatype (?t2) as ?type2)
  }

```

Our java app uses RDF4J to create triples that are later insert into Stardog. Here’s an excerpt:

```auto
    Literal literal;
    if (property.getLiteralType() != null) {
      IRI typeIri = this.vf.createIRI(property.getLiteralType());
      literal = this.vf.createLiteral(value, typeIri);
    } else {
      literal = this.vf.createLiteral(value);
    }
    this.trips.add(this.vf.createStatement(parentIndividual, this.vf.createIRI(property.getPredicate()), literal));

```

Stardog seems to be kicking back this error message when we encounter the format in question:  
`14:22:14.215 [ForkJoinPool-1-worker-5] WARN [c.c.c.s.r.r.CustomSPARQLProtocolSession] Server reports problem: {"message":"Data block for update operation could not be parsed: '2017-03-02T14:14:23.000-0800' is not a valid value for datatype http://www.w3.org/2001/XMLSchema#dateTime [line 10]","code":"MalformedQuery"}`

Is this a bug? Am I missing something?

Thank You,  
Peter Neorr  
Champion Technology Company

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [September 7, 2017, 2:42pm UTC](https://community.stardog.com/t/xsd-datetime-format/546/2 "2017-09-07T14:42:50Z")

</div>

Hi,

There are two things at work here:

1. `"2017-03-02T13:31:59.000-0800"` is indeed an invalid value for an xsd:dateTime. When specifying the time zone, it requires a colon between the hours and minutes section, so you would need `"2017-03-02T13:31:59.000-08:00"`, which will load properly. `"2017-03-02T13:31:59.000Z"` is perfectly valid.

2. The query works because the [RDF spec](https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal) dictates that we accept ill-typed literals because while they are semantically inconsistent, they are "not syntactically ill-formed." They will, however, not function as actual xsd:dateTimes, e.g., when using them in dateTime functions:

```auto
Stephens-iMac:community stephen$ stardog query support 
'select * where { 
    bind ("Stephen"^^xsd:dateTime as ?t1) 
    bind (datatype(?t1) as ?type1)  
    bind( hours(?t1) as ?h1)
}'

+-------------------------+--------------+-------+
| t1 | type1 | h1 |
+-------------------------+--------------+-------+
| "Stephen"^^xsd:dateTime | xsd:dateTime | |
+-------------------------+--------------+-------+

```

---

<div class="post-metadata">

**Author:** ![peterneorr](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/peterneorr/32/31_2.png) [@peterneorr](https://community.stardog.com/u/peterneorr)\
**Post date:** [September 7, 2017, 3:04pm UTC](https://community.stardog.com/t/xsd-datetime-format/546/3 "2017-09-07T15:04:19Z")

</div>

Thank you Stephen! I didn’t even notice the missing colon in the time zone offeset. I guess we can add some pre-processing to fix these in our input.

😃

-Peter

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [September 21, 2017, 3:04pm UTC](https://community.stardog.com/t/xsd-datetime-format/546/4 "2017-09-21T15:04:23Z")

</div>

Closed on September 21, 2017, 3:04pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
