c# - How to get work week from two dates -


this question has answer here:

lets say, have 2 date order date - 1/1/2014 , delivery date - 6/2/2014. if want calculate how work week taken (order date-delivery date), how can in c#.

if want number of worked days in date range, can use this:

        var = datetime.today.adddays(-10);         var = datetime.today;         var daysofweek = new dayofweek[] { dayofweek.monday, dayofweek.tuesday                                           , dayofweek.wednesday, dayofweek.friday                                           , dayofweek.thursday };           var days = enumerable.range(0, 1 + to.subtract(from).days)                              .select((n, i) => from.adddays(i).dayofweek)                              .where(n => daysofweek.contains(n.dayofweek)); 

if want number of weeks during date range, use this:

        (int)((to - from).totaldays/7) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -