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
Post a Comment