I want to calculate the difference between the two dates but want to exclude the weekends from it . Below is the format of dates :
CreateDate - 2017-08-29 1
One more python way using isoweekday():
import datetime, pprint
# isoweekday: Monday is 1 and Sunday is 7
start_date = datetime.date(2017, 10, 1)
end_date = datetime.date(2017, 12, 31)
days = end_date - start_date
valid_date_list = {(start_date + datetime.timedelta(days=x)).strftime('%d-%b-%Y')
for x in range(days.days+1)
if (start_date + datetime.timedelta(days=x)).isoweekday() <= 5
}
print("Business Days = {}".format(len(valid_date_list)))