# Xsd:time not working

**URL:** <https://community.stardog.com/t/xsd-time-not-working/1504>\
**Category:** Support\
**Created:** [March 6, 2019, 5:39pm UTC](https://community.stardog.com/t/xsd-time-not-working/1504 "2019-03-06T17:39:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlbis](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/dlbis/32/721_2.png) [@dlbis](https://community.stardog.com/u/dlbis)\
**Post date:** [March 6, 2019, 5:39pm UTC](https://community.stardog.com/t/xsd-time-not-working/1504/1 "2019-03-06T17:39:04Z")

</div>

I am trying to create a valid time variable with xsd:time in SPARQL but I am getting an error message. I am able to do the same for a date with xsd:date however.

select ?eventDate (xsd:date((strbefore(?eventDate, " "))) as ?date) (xsd:time(strafter(?eventDate, " ")) as ?time)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/e0bea52f36b5a036a1e2d538bbfc4c808ca7f0d4.png)

In previous posts, it was mentionned that future versions will support that function. When is it supposed to be supported?

Thanks

---

<div class="post-metadata">

**Author:** ![evren](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/evren/32/1515_2.png) [@evren](https://community.stardog.com/u/evren)\
**Post date:** [March 6, 2019, 9:28pm UTC](https://community.stardog.com/t/xsd-time-not-working/1504/2 "2019-03-06T21:28:31Z")

</div>

You do not need casting here. For creating typed literals from strings you can use the builtin `strdt` function as in `(strdt(strafter(?eventDate, " "), xsd:time) as ?time)`.

Best,  
Evren

---

<div class="post-metadata">

**Author:** ![mgns](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mgns](https://community.stardog.com/u/mgns)\
**Post date:** [March 18, 2019, 2:22pm UTC](https://community.stardog.com/t/xsd-time-not-working/1504/3 "2019-03-18T14:22:02Z")

</div>

There is a slight difference: Casting validates the lexical value and strdt doesn't. So using strdt is prone to data corruption. Ex:  
`SELECT ?time (datatype(?time) AS ?dt) { BIND (strdt("2019-0909", xsd:time) as ?time) }`

---

<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:** [April 1, 2019, 2:22pm UTC](https://community.stardog.com/t/xsd-time-not-working/1504/4 "2019-04-01T14:22:14Z")

</div>

Closed on April 1, 2019, 2:22pm UTC

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