Date calculation in Python

If you want to get the date and time of yesterday, you can create a timedelta for one day and pull the date object as it is.

>>> import datetime
>>> from datetime import timedelta
>>> t = timedelta(days = 1)
>>> d = datetime.date.today()
>>> d
datetime.date(2013, 3, 27)
>>> d - t
datetime.date(2013, 3, 26)

8.1. datetime — basic date and time types

Recommended Posts

Date calculation in python
Date calculation in Python
Date manipulation in Python
Get date in Python
Shapley value calculation in Python
String date manipulation in Python
Sort by date in python
Quantum chemistry calculation in Python (Psi4)
Accelerometer Alan Variance Calculation in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
SendKeys in Python
Python date arithmetic
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Conversion of string <-> date (date, datetime) in Python
Let's make a combination calculation in Python
Time comparison: Correlation coefficient calculation in Python
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python