diff --git a/pom.xml b/pom.xml
index 27a2667..3017972 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,11 @@
           <version>4.11</version>
           <scope>test</scope>
       </dependency>
+      <dependency>
+          <groupId>joda-time</groupId>
+          <artifactId>joda-time</artifactId>
+          <version>2.2</version>
+      </dependency>
   </dependencies>
   <build>
     <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
index f43ba9e..53c90ab 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
@@ -112,7 +112,6 @@
     //todo: connection to database module!
     public Map<String, String> getResource(String id) {
         return tester.get(id);
-
     }
 
     private Map<String, Map> tester() {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
index 6db54f4..60bd4b8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
@@ -18,6 +18,7 @@
  */
 public class MetaQuerySerializer {
 
+
     private ObjectMapper mapper;
     private MetaTypes types;
 
@@ -30,77 +31,142 @@
     //todo: how to handle regex types?
     // only handles AND relation between query attributes and values!
     // value pair : pubdate=<date>, pubPlace=<place>, etc.
-    public List serializeQueries(Map<String, String> queries) {
-        boolean single = true;
+    public List serializeQueries(Map<String, String> queries, TYPE type) {
+        boolean extend, single = true;
         boolean multypes = queries.keySet().size() > 1;
         List metavalue;
         String def_key = null;
         if (queries.size() > 1)
             single = false;
+        switch (type) {
+            case EXTEND:
+                extend = true;
+                break;
+            default:
+                extend = false;
+                break;
+        }
 
         List value = new ArrayList<>();
+        Map<String, String> dates = new LinkedHashMap<>();
         for (String key : queries.keySet()) {
             if (!multypes)
                 def_key = key;
-            String[] dr;
-            if (queries.get(key).contains("~")) {
-                dr = queries.get(key).split("~");
-                Map fd = types.createTerm(null, null, dr[0].trim(), "korap:date");
-                Map td = types.createTerm(null, null, dr[1].trim(), "korap:date");
-                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-                value.add(dg);
-                continue;
-            } else if (queries.get(key).contains(">")) {
-                dr = queries.get(key).split(">");
-                Map fd = types.createTerm(null, null, dr[0].trim(), "korap:date");
-                Map td = types.createTerm(null, null, dr[1].trim(), "korap:date");
-                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-                value.add(dg);
-                continue;
-            } else if (queries.get(key).contains("<")) {
-                dr = queries.get(key).split("<");
-                Map fd = types.createTerm(null, null, dr[0].trim(), "korap:date");
-                Map td = types.createTerm(null, null, dr[1].trim(), "korap:date");
-                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-                value.add(dg);
+            if (key.contains("~") | key.contains(">") |
+                    key.contains("<")) {
+                System.out.println("values " + key);
+                dates.put(key, queries.get(key));
                 continue;
             }
 
+//            if (queries.get(key).contains("~")) {
+//                dr = queries.get(key).split("~");
+//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
+//                Map td = types.createTerm(dr[1].trim(), "korap:date");
+//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
+//                value.add(dg);
+//                continue;
+//            } else if (queries.get(key).contains(">")) {
+//                dr = queries.get(key).split(">");
+//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
+//                Map td = types.createTerm(dr[1].trim(), "korap:date");
+//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
+//                value.add(dg);
+//                continue;
+//            } else if (queries.get(key).contains("<")) {
+//                dr = queries.get(key).split("<");
+//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
+//                Map td = types.createTerm(dr[1].trim(), "korap:date");
+//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
+//                value.add(dg);
+//                continue;
+//            }
+
             Map term;
             if (multypes)
                 term = types.createTerm(key, null, queries.get(key).trim(), null);
             else
-                term = types.createTerm(null, null, queries.get(key).trim(), null);
+                term = types.createTerm(queries.get(key).trim(), null);
             value.add(term);
         }
 
+        String[] proc = processDates(dates);
+        int idx = 0;
+        if (proc[0] != null && proc[0].equals("r")) {
+            Map term1 = types.createTerm(proc[1], "korap:date");
+            Map term2 = types.createTerm(proc[2], "korap:date");
+            Map group = types.createGroup("between", "pubDate", Arrays.asList(term1, term2));
+            value.add(group);
+            idx = 3;
+        }
+
+        for (int i = idx; i < proc.length; i++) {
+            Map term = types.createTerm("pubDate", null, proc[i], "korap:date");
+            value.add(term);
+        }
+
+
         // todo: missing: - takes only one resource, but resources can be chained!
         // only filters, no extension
-//        metavalue.put("meta", Arrays.asList(types.createMetaFilter(resource, (Map) value.get(0))));
-        if (single)
-            metavalue = Arrays.asList(types.createMetaFilter((Map) value.get(0)));
-        else {
+        if (single) {
+            if (extend)
+                metavalue = Arrays.asList(types.createMetaExtend((Map) value.get(0)));
+            else
+                metavalue = Arrays.asList(types.createMetaFilter((Map) value.get(0)));
+        } else {
             Map group;
             if (!multypes)
                 group = types.createGroup("and", def_key, value);
             else
                 group = types.createGroup("and", null, value);
-//            metavalue.put("meta", Arrays.asList(types.createMetaFilter(resource, group)));
-            metavalue = Arrays.asList(types.createMetaFilter(group));
+            if (extend)
+                metavalue = Arrays.asList(types.createMetaExtend(group));
+            else
+                metavalue = Arrays.asList(types.createMetaFilter(group));
         }
         return metavalue;
     }
 
-    public String stringify(Map<String, String> queries) throws IOException {
+    //todo: resource id must be added!
+    public String stringify(Map<String, String> queries, TYPE type) throws IOException {
         Map f = new HashMap();
-        f.put("meta", serializeQueries(queries));
+        f.put("meta", serializeQueries(queries, type));
         return mapper.writeValueAsString(f);
     }
 
+    //fixme: only allows for one until and since entry!!
+    private String[] processDates(Map<String, String> dates) {
+        if (dates.isEmpty())
+            return new String[1];
+        boolean until = false, since = false;
+        String[] el = new String[dates.keySet().size() + 1];
+        int idx = 1;
+        for (String key : dates.keySet()) {
+            if (key.contains("<")) {
+                since = true;
+                el[1] = dates.get(key);
+            }
+            if (key.contains(">")) {
+                until = true;
+                el[2] = dates.get(key);
+            } else
+                el[idx] = dates.get(key);
+            idx++;
+        }
+        if (since && until)
+            el[0] = "r";
+        return el;
+    }
+
     public JsonNode jsonify(Map<String, String> queries) {
-        List s = serializeQueries(queries);
+        List s = serializeQueries(queries, TYPE.FILTER);
         return mapper.valueToTree(s);
     }
 
 
+    public enum TYPE {
+        EXTEND, FILTER
+    }
+
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaTypes.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaTypes.java
index 887f176..fcabf20 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaTypes.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaTypes.java
@@ -2,6 +2,7 @@
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.joda.time.DateTime;
 
 import java.io.IOException;
 import java.util.LinkedHashMap;
@@ -14,6 +15,9 @@
  */
 public class MetaTypes {
 
+    public static final String Y = "yyyy";
+    public static final String YM = "yyyy-mm";
+    public static final String YMD = "yyyy-mm-dd";
     private ObjectMapper mapper;
 
     public MetaTypes() {
@@ -39,13 +43,17 @@
             type = "korap:term";
         term.put("@type", type);
         if (field != null)
-            term.put("@field", "korap:field#" + field);
+            term.put("field", "korap:field#" + field);
         if (subtype != null)
             term.put("subtype", "korap:value#" + subtype);
         term.put("@value", value);
         return term;
     }
 
+    public Map createTerm(String value, String type) {
+        return createTerm(null, null, value, type);
+    }
+
     public Map createResourceFilter(String resource, Map value) {
         Map meta = new LinkedHashMap();
         meta.put("@type", "korap:meta-filter");
@@ -80,8 +88,18 @@
         return meta;
     }
 
-    public String formatDate(String date) {
-        return "";
+    public String formatDate(long date, String format) {
+        DateTime time = new DateTime(date);
+        switch (format) {
+            case YM:
+                String s = time.getYear() + "-" + time.getMonthOfYear();
+                return s;
+            case YMD:
+                String s1 = time.getYear() + "-" + time.getMonthOfYear() + "-" + time.getDayOfMonth();
+                return s1;
+            default:
+                return String.valueOf(time.getYear());
+        }
     }
 
     public Map mapify(String s) throws IOException {
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index 71ca546..c44d036 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,11 +1,13 @@
 import de.ids_mannheim.korap.query.serialize.MetaCollectionSerializer;
 import de.ids_mannheim.korap.query.serialize.MetaQuerySerializer;
+import org.joda.time.DateTime;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -16,19 +18,21 @@
 @RunWith(JUnit4.class)
 public class MetaQuerySerializationTest {
 
-    private MetaQuerySerializer serializer;
+    private MetaQuerySerializer querySerializer;
+    private MetaCollectionSerializer collSerializer;
 
     public MetaQuerySerializationTest() {
-        serializer = new MetaQuerySerializer();
+        querySerializer = new MetaQuerySerializer();
+        collSerializer = new MetaCollectionSerializer();
     }
 
     @Test
     public void test() throws IOException {
         Map<String, String> j = new HashMap();
         j.put("author", "Goethe");
-        j.put("pubPLace", "Erfurt");
+        j.put("pubPlace", "Erfurt");
         j.put("textClass", "wissenschaft");
-        String s = serializer.stringify(j);
+        String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
 //        System.out.println("value reference " + s);
     }
 
@@ -36,16 +40,23 @@
     public void testSingle() throws IOException {
         Map<String, String> j = new HashMap();
         j.put("textClass", "wissenschaft");
-        String s = serializer.stringify(j);
+        String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
 //        System.out.println("value reference test single " + s);
     }
 
     @Test
     public void testResourceMeta() throws IOException {
-        MetaCollectionSerializer ser = new MetaCollectionSerializer();
-        String s = ser.serialize("25");
-        System.out.println(" --- RESULT JSON " + s);
+        String s = collSerializer.serialize("25");
+//        System.out.println(" --- RESULT JSON " + s);
+    }
 
-
+    @Test
+    public void testDates() throws IOException {
+        Map<String, String> queries = new LinkedHashMap<>();
+        queries.put("<pubDate", String.valueOf(new DateTime().getMillis()));
+        queries.put(">pubDate", String.valueOf(new DateTime().getMillis()+2));
+        queries.put("author", "Goethe");
+        String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
+        System.out.println("value : "+ f);
     }
 }
