前月1日を出す
def getLastMonthStartDay():
# 今日を取得
today = datetime.datetime.today()
# 当月1日を出す
thismonth = datetime.datetime(today.year, today.month, 1)
# 前月末日を出す
lastmonth = thismonth + datetime.timedelta(days=-1)
# 前月1日を出す
lastmonthFirstday = datetime.datetime(lastmonth.year, lastmonth.month, 1)
print(lastmonthFirstday.strftime('%Y-%m-%d'))
return lastmonthFirstday.strftime('%Y-%m-%d')
来月末日の値を出す
def getNextMonthLastDay():
# 今日を取得
today = datetime.datetime.today()
# 翌々月を出す
nextmoth = today + relativedelta(months=2)
# 翌々月1日を出す
thismonth = datetime.datetime(nextmoth.year, nextmoth.month, 1)
# 前月末日の値を出す
lastmonth = thismonth + datetime.timedelta(days=-1)