Is there a way to access a Date as milliseconds since epoch (Date.getTime()) in mongodb aggregation pipeline -


mongodb provides lots of 'date aggregation operators' such $dayofyear, $dayof month, , $millisecond. $millisecond function returns milliseconds of time stamp range of 0-999.

is there way access date object milliseconds since epoch in aggregation pipeline?

thanks,

nathan

you can $subtract epoch date , result date milliseconds since epoch:

db.collection.aggregate([     {$project : {         "dateinmillis" : {$subtract : ["$date", new date("1-1-1970")] }     }} ]); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -