Reputation: 23
I need to figure out in python how to (in pesudo)
x = month-begin
y = month-end
for range in (x through y)
print(dates of weekdays - Monday trough Friday)
Upvotes: 0
Views: 484
Reputation: 1280
Use the datetime module:
import datetime
current=datetime.datetime(2018,8,14,14,00)
end=datetime.datetime(2018,12,1,14,00)
while current<end:
current+=datetime.timedelta(days=1)
if current.weekday()<5:
print(current.strftime("%-m/%-d"))
Upvotes: 1
Reputation: 1961
Use date.weekday(). Following your pseudo-code example:
for day in range (x through y)
if day.weekday() in range(0,5):
print(day)
Upvotes: 2