BASH
YEAR=2014
MONTH=12
date -d${MONTH}/01/${YEAR}-1days+1month '+%Y%m%d'
result
20141231
PYTHON
from datetime import date, timedelta
from dateutil.relativedelta import relativedelta
year = 2014
month = 12
print date(year, month , 1) + relativedelta(months=1) + timedelta(days=-1)
result
2014-12-31
Recommended Posts