문제

How can I get previous month and year using python. Is it possible to get it using datetime module

I want to get it like following example

 current:  2012-03      prev   2012-02
 current:  2012-01      prev   2011-12
도움이 되었습니까?

해결책

use

 date(2012,3,1)+relativedelta(years=-1)

see http://labix.org/python-dateutil

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top