Created
April 30, 2018 06:11
-
-
Save liladas/45db5eca1cf9947eb32f760ac6fa2f8d to your computer and use it in GitHub Desktop.
Getting previous time windows
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
#!/usr/bin/env python3 | |
from datetime import datetime, timedelta | |
current_time = datetime.now() | |
start_time = current_time.replace(microsecond=0,second=0,minute=0,hour=0)-timedelta(days=1) | |
end_time = current_time.replace(microsecond=0,second=0,minute=0,hour=0)-timedelta(seconds=1) | |
print("Getting All Data from Day Prior") | |
print("Time of invocation:", current_time) | |
print("Start Time Window :", start_time) | |
print("End Time Window :", end_time) | |
start_time = current_time.replace(microsecond=0,second=0,minute=0)-timedelta(hours=1) | |
end_time = current_time.replace(microsecond=0,second=0,minute=0)-timedelta(seconds=1) | |
print("Getting All Data from Hour Prior") | |
print("Time of invocation:", current_time) | |
print("Start Time Window :", start_time) | |
print("End Time Window :", end_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment