[Gooch, John]
> Thank you for the idea, I could have been more clear that days part of the
> date isn't important. Here is what I came up with:
>
>    currentDate = datetime.datetime.fromtimestamp( time.time() )

Easier:

    today = datetime.date.today()

>    archMonth = 0
>    archYear = 0
>    if ( currentDate.month == 1 ):
>        archMonth = 12
>        archYear = currentYear - 1
>    else:
>        archMonth = currentDate.month -1
>        archYear = currentDate.year
>    archDate = datetime.datetime( archYear, archMonth, 1 )#Year/Month of
> target files

Easier:

    lastmonth = today.replace(day=1) - datetime.timedelta(days=1)

IOW, it moves to the first day of the current month, and then
subtracts one day.  That moves you to the last day of the preceding
month.

    lastmonth.month

is then the month you want, and

    lastmonth.year

is the year you want.
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to