Custom Search

Friday, March 26, 2010

How find last day of a month in python

How find last day of a month in python
How find first and last date of a month in python

>>> import calendar
>>> import datetime
>>> calendar.mdays[datetime.date.today().month]
31
----------------------------------
date = datetime.date.today()
start_date = datetime.datetime(date.year, date.month, 1)
end_date = datetime.datetime(date.year, date.month, calendar.mdays[date.month])

----------------------------------

No comments:

Post a Comment