# Null handling in SPARQL with StarDog

**URL:** <https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471>\
**Category:** Support\
**Created:** [February 11, 2019, 3:23pm UTC](https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471 "2019-02-11T15:23:29Z")\
**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:** [February 11, 2019, 3:23pm UTC](https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471/1 "2019-02-11T15:23:29Z")

</div>

Hi,

I have an event class with start and end dates and there is no end date triple for the event before its actual end. To select unfinished events, I usually do something like:

optional { ?s ontology:endDate ?endDate}  
filter (?endDate = "")

However, with StarDog,that does not return anything. I have also used the following without success:

filter (str(?endDate) = "")  
filter (strlen(str(?endDate)) = 0)  
filter( isBLANK(?endDate) )  
filter( ?endDate = UNDEF)  
filter( ?endDate = NIL)

How can I handle null in StarDog?

Thanks

---

<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:** [February 11, 2019, 4:25pm UTC](https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471/2 "2019-02-11T16:25:53Z")

</div>

If by NULL you mean there is no binding for ?endDate, then you want the following:

```auto
optional { ?s ontology:endDate ?endDate}
filter (!bound(?endDate))

```

Or, more concisely:

```auto
filter not exists { ?s ontology:endDate ?endDate }

```

---

<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:** [February 11, 2019, 5:23pm UTC](https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471/3 "2019-02-11T17:23:26Z")

</div>

The two solutions are working fine but the first one is faster.

Thanks for your fast answer Stephen!

---

<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:** [February 25, 2019, 5:23pm UTC](https://community.stardog.com/t/null-handling-in-sparql-with-stardog/1471/4 "2019-02-25T17:23:28Z")

</div>

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