**I have this snippet right here which saves a user in my MongoDB:**

```
router.post('/adduser', function(req, res) {
    var db = req.db;
    var document = req.body;
    var codeResponse = code();
    var timestamp = new Date();
    document.code = codeResponse;
    document.timestamp = timestamp;
    db.collection('userlist').insert(document, function(err, result){
        res.send(
            (err === null) ? { msg: '',code: codeResponse } : { msg: err }
        );
    }); });

```

As you can see it also generates a `timestamp via the new Date();` function in JS.

**How can retrieve users by week?**

I tried this:

```
router.get('/winnerlist', function(req, res) {
    var db = req.db;
    var start = new Date(2014, 6, 14);
    var end = new Date(2014, 6, 29);
    db.collection('userlist').find({"timestamp": {"$gte": start, "$lt": end}}).toArray(function (err, items) {
        res.json(items);
    });
});

```