I am somewhat new to Python. I need two functions. The first is supposed to get the current date and then return the starting and ending dates of that month e.g if current date is 02/12/2012, it should return 02/01/2012 and 02/29/2012. The second function does something similar but instead returns the beginning & ending dates of the previous month. Please how can I do that in Python? Thanks in anticipation
Share
OK — I’m bored.
First, unless you are from Mars or somewhere, we here on Earth begin every month with
1. Safe assumption.The only challenging part is the number of days in the month. You can get that from calendar.monthrange()
The second number there is the ending day of that month in that year. So you can do:
Prints: