Get Number of weekdays between two dates in Mongo DB
<p>I am new to Mongo DB. Can anyone help me in how to get the number of weekdays between two Given dates.</p>

<p><strong>$dayOfWeek</strong> of a date will give the value of the date 0 for sunday and 7 for saturday.</p>

<p>But my question is how can i increment the date from start date to end date to find the number of weekdays.</p>

<p>Sample Data:</p>

<pre><code> &gt; db.data.insert({"startDate":ISODate('2016-0101'), "endDate":ISODate('2016-02-02')})  

    WriteResult({ "nInserted" : 1 })
    &gt; db.data.find().pretty()
    { 
            "_id" : ObjectId("57c6e6a6a1e49d654caca17a"), 
            "startDate" : ISODate("2016-01-01T00:00:00Z"),
            "endDate" : ISODate("2016-02-02T00:00:00Z")
    }
</code></pre>

<p>Now need to find the number of Weekdays between the Start Date (2016-01-01) and End Date (2016-02-02).</p>

<p>I can write a function which accepts the start date and end date, but in that function how to iterate from the start date to end date?</p>

<p>Any help is requested.</p>