Created
February 3, 2021 16:21
-
-
Save gomesfellipe/e7c6f9db01fdd9b04ec438c033f40eb5 to your computer and use it in GitHub Desktop.
Calcular dias de vida em R e em Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python ----------------------------------------------------------------------- | |
from datetime import datetime, timedelta | |
today = datetime.today() | |
born = datetime.strptime('1993-12-14', '%Y-%m-%d') | |
# Quantos dias de vida | |
print("Time difference of", str((today-born).days), "days") | |
# Completa 10.000 dias de vida em: | |
str(born + timedelta(days=10000)) | |
# Faltam | |
print("Time difference of",str((born + timedelta(days=10000) - today).days), "days") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R ---------------------------------------------------------------------------- | |
born <- as.Date("1993-12-14") | |
today <- Sys.Date() | |
# Quantos dias de vida | |
difftime(today, born) | |
# Completa 10.000 dias de vida em: | |
born+days(10000) | |
# Faltam | |
difftime(born+days(10000), today) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment