diff --git a/modules/conop/src/compound.hh b/modules/conop/src/compound.hh
index e33a7e38cfb840ebc5e5e050fbd7da55073e2c68..975664a146b4e09914c2d547a858240fb7ec2dc2 100644
--- a/modules/conop/src/compound.hh
+++ b/modules/conop/src/compound.hh
@@ -52,11 +52,11 @@ struct Date {
   
   static Date FromString(const StringRef& str)
   {
-    assert(str[4]=='-');
-    assert(str[7]=='-');
-    std::pair<bool, int> year=str.substr(0,4).to_int();
-    std::pair<bool, int> month=str.substr(5,2).to_int();
-    std::pair<bool, int> day=str.substr(8, 2).to_int();
+    std::vector<StringRef> parts=str.split('-');
+    assert(parts.size()==3);
+    std::pair<bool, int> year=parts[0].to_int();
+    std::pair<bool, int> month=parts[1].to_int();
+    std::pair<bool, int> day=parts[2].to_int();
     assert(year.first); assert(month.first); assert(day.first);
     return Date(year.second, month.second, day.second);
   }
diff --git a/modules/conop/src/compound_lib.cc b/modules/conop/src/compound_lib.cc
index c05e60fb6d2ce72343e6ab44d637526c16639707..76efe4ac70f8acf781eab944ab47c8b41dac05f7 100644
--- a/modules/conop/src/compound_lib.cc
+++ b/modules/conop/src/compound_lib.cc
@@ -116,14 +116,22 @@ void CompoundLib::AddCompound(const CompoundPtr& compound)
     sqlite3_bind_text(stmt, 6, compound->GetFormula().c_str(),
                       compound->GetFormula().length(), NULL);
     std::stringstream ss;
-    ss << compound->GetCreationDate().year << "-" 
-       << compound->GetCreationDate().month << "-" 
-       << compound->GetCreationDate().day;
+    ss << compound->GetCreationDate().year << "-";
+    ss.fill('0');
+    ss.width(2);
+    ss << compound->GetCreationDate().month << "-";
+    ss.fill('0');
+    ss.width(2);
+    ss << compound->GetCreationDate().day;
     String date=ss.str();
     ss.str("");
-    ss << compound->GetModificationDate().year << "-" 
-       << compound->GetModificationDate().month << "-" 
-       << compound->GetModificationDate().day;
+    ss << compound->GetModificationDate().year << "-";
+    ss.fill('0');
+    ss.width(2);
+    ss << compound->GetModificationDate().month << "-";
+    ss.fill('0');
+    ss.width(2);
+    ss << compound->GetModificationDate().day;
     sqlite3_bind_text(stmt, 7, date.c_str(), date.length(), NULL);
     date=ss.str();
     sqlite3_bind_text(stmt, 8, date.c_str(), date.length(), NULL);