Created
December 16, 2023 17:27
-
-
Save renegarcia/383a36e0d08c62484407c749d51eca4f to your computer and use it in GitHub Desktop.
Elapsed days from daterange
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
from datetime import datetime | |
# Formato de la fecha: 'dd-mm-yyyy' | |
fecha_inicio = '01-01-2023' | |
fecha_fin = '16-12-2023' | |
# Convertir las cadenas a objetos datetime | |
fecha_inicio = datetime.strptime(fecha_inicio, '%d-%m-%Y') | |
fecha_fin = datetime.strptime(fecha_fin, '%d-%m-%Y') | |
# Calcular la diferencia entre las fechas | |
diferencia = fecha_fin - fecha_inicio | |
# Imprimir el número de días | |
print('Número de días transcurridos:', diferencia.days) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment