LoginSignup
20
13

More than 5 years have passed since last update.

[Python3]日付の差分を取得する

Posted at

日数計算という便利なサイトがあります。
http://keisan.casio.jp/exec/system/1177658154

これっぽいのを再現します。

calc_days.py
import datetime
a = datetime.date(2015, 4, 1)
b = datetime.date(2016, 1, 25)
print((b-a).days)
# 299

ちなみにこの値は、初日を含んでいないので、〜日目の表記をしたい場合は+1しましょう。

20
13
0

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
20
13