diff --git a/product/ZSQLCatalog/SearchKey/DateTimeKey.py b/product/ZSQLCatalog/SearchKey/DateTimeKey.py
index 9c23d28cd6e2fdc77ec9516f8b5e0d7a4fec083b..1ac5b428c285cc73bd22d7dc5536255144f8cf53 100644
--- a/product/ZSQLCatalog/SearchKey/DateTimeKey.py
+++ b/product/ZSQLCatalog/SearchKey/DateTimeKey.py
@@ -72,7 +72,7 @@ def castDate(value):
       value = _DateTime(value, **date_kw)
     except DateTimeError:
       delimiter_count = countDelimiters(value)
-      if delimiter_count < 3:
+      if delimiter_count is not None and delimiter_count < 2:
         split_value = value.split()
         if split_value[-1].lower() in timezone_dict:
           value = '%s %s' % (date_completion_format_dict[date_kw.get('datefmt')][delimiter_count] % (' '.join(split_value[:-1]), ), split_value[-1])
@@ -101,6 +101,8 @@ def countDelimiters(value):
   assert isinstance(value, basestring)
   # Detect if timezone was provided, to avoid counting it as in precision computation.
   split_value = value.split()
+  if not split_value:
+    return None
   if split_value[-1].lower() in timezone_dict:
     value = ' '.join(split_value[:-1])
   # Count delimiters
diff --git a/product/ZSQLCatalog/tests/testSQLCatalog.py b/product/ZSQLCatalog/tests/testSQLCatalog.py
index 2650ce101ab560bc32f066f050a920d60916fd18..d5c751671725556260b86826e69170ffd049df5f 100644
--- a/product/ZSQLCatalog/tests/testSQLCatalog.py
+++ b/product/ZSQLCatalog/tests/testSQLCatalog.py
@@ -363,6 +363,20 @@ class TestSQLCatalog(unittest.TestCase):
         
   def test_DateTimeKey(self):
     self._testDateTimeKey('date')
+    # XXX: It is unknown what these tests should produce when used with a
+    # related key: should the join happen or not ?
+    self.catalog(
+      ReferenceQuery(ReferenceQuery([], operator='or'), operator='and'),
+      {'date': ' '})
+    self.catalog(
+      ReferenceQuery(ReferenceQuery([], operator='or'), operator='and'),
+      {'date': '<>2008/01/01'})
+    self.catalog(
+      ReferenceQuery(ReferenceQuery([], operator='or'), operator='and'),
+      {'date': '<'})
+    self.catalog(
+      ReferenceQuery(ReferenceQuery([], operator='or'), operator='and'),
+      {'date': '00:00:00'})
 
   def test_relatedDateTimeKey(self):
     self._testDateTimeKey('related_date')