LoginSignup
3
3

More than 5 years have passed since last update.

指定月の月末日を取得する

Last updated at Posted at 2013-05-16

BASH

YEAR=2014
MONTH=12
date -d${MONTH}/01/${YEAR}-1days+1month '+%Y%m%d'
結果
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)
結果
2014-12-31
3
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3