2nd and 4th Saturday of the month

By default, current month is used , you can change the below code to any month and year.
from  datetime import date
year=date.today().year   # change this to use year as input
month=date.today().month # change this to use month as input

dt=date(year,month,1)    # first day of month
first_w=dt.isoweekday()  # weekday of 1st day of the month
saturday2=14-first_w
dt=date(year,month,saturday2)
print(dt.day,dt.month,dt.year)
To display 4th Satruday, add this code at the end.
saturday4=28-first_w
dt=date(year,month,saturday4)
print(dt.day,dt.month,dt.year)
All Date Objects


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer