Python Forum
Unable to pass date timestamp as Parameters :
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to pass date timestamp as Parameters :
#1
Hi Team ,

Need small help .. I just want to pass time stamps for end and start . How can I do this in below code
could you please help me with this

For example
Start as todays morning 09:15 AM
and end as current time stamp

tech_list = ['AAPL','GOOG','MSFT','AMZN']
end = datetime.now()
start = datetime(end.year - 1,end.month,end.day)
for stock in tech_list:   
    # Set DataFrame as the Stock Ticker
    globals()[stock] = DataReader(stock,'yahoo',start,end)
Reply
#2
you can use time to get start and end time (run once before starting process, once after then subtract difference)
Or a better approach would be to use time.process_time
example
from time import process_time 

def fibo(n):
   if n <= 1:
       return n
   else:
       return(fibo(n-1) + fibo(n-2))

start_time = process_time()  
print(f"\nStarting process at: {start_time}")  

# pass some time
for x in range (30):
    print(f"{fibo(x)} ", end ='')

stop_time = process_time()

print(f"\nTotal time: {stop_time - start_time} seconds.\n")
output of above:
Output:
Starting process at: 0.01270591 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 Total time: 0.35556174 seconds.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 212 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 586 Jan-20-2024, 04:45 AM
Last Post: 1418
  How to pass encrypted pass to pyodbc script tester_V 0 851 Jul-27-2023, 12:40 AM
Last Post: tester_V
  [SOLVED] Alternative to regex to extract date from whole timestamp? Winfried 6 1,832 Nov-16-2022, 01:49 PM
Last Post: carecavoador
  error in timestamp Led_Zeppelin 3 3,201 Jun-15-2022, 08:28 PM
Last Post: deanhystad
  error in timestamp Led_Zeppelin 0 1,006 Jun-10-2022, 07:59 PM
Last Post: Led_Zeppelin
  Unable to Loop Over Date gdbengo 2 1,288 Jan-09-2022, 05:11 PM
Last Post: menator01
  Date format and past date check function Turtle 5 4,228 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 2,223 Feb-06-2021, 10:48 PM
Last Post: eddywinch82
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,551 Sep-07-2020, 08:02 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020