1
1

More than 3 years have passed since last update.

datetimeで日時のBool演算

Last updated at Posted at 2021-01-30

日時のTrue/False比較ができる。
後の方が大。

import datetime

date1 = datetime.datetime(2021, 1, 30, 9, 0, 00, 00)
date2 = datetime.datetime(2021, 1, 30, 10, 0, 00, 00)
date3 = datetime.datetime(2021, 1, 31, 1, 0, 00, 00)

print(date1)
print(date2)
print(date3)

b1 = date < date2 < date3
print(b1)
b2 = date < date3 < date2
print(b2)

2021-01-30 09:00:00
2021-01-30 10:00:00
2021-01-31 01:00:00
True
False

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。

Twitter
Medium

1
1
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
1
1