diff --git a/modules/conop/src/compound.hh b/modules/conop/src/compound.hh
index 83862af3bd93e4614a2174417501afcd30a9ec90..45466a1cc228bd824e43aeedac82dfd47498077b 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 c423e0a12155e8be67180a8ddc46e96f2f39db86..020c3468c35d95a284e98629963d61b383f72f36 100644
--- a/modules/conop/src/compound_lib.cc
+++ b/modules/conop/src/compound_lib.cc
@@ -117,14 +117,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);