datetime question
Rami Chowdhury
rami.chowdhury at gmail.com
Fri Oct 30 16:49:49 EDT 2009
On Fri, 30 Oct 2009 13:03:32 -0700, Victor Subervi
<victorsubervi at gmail.com> wrote:
> Hi;
> I have this code:
>
> today = datetime.date.today()
> day = today.day
> mo = today.month
> yr = today.year
>
> Works great. What I need to calculate is the length of days in the
> given month. How do I do that?
> TIA,
> Victor
Off the top of my head:
You could calculate it fairly easily by subtracting a datetime object
representing the first of this month from a datetime object representing
the first of next month; that'd give you a timedelta object with the
number of days.
Alternatively, of course, you could look up the number of days in the
current month using the calendar module ;-)
--
Rami Chowdhury
"Never attribute to malice that which can be attributed to stupidity" --
Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
More information about the Python-list
mailing list