Questions tagged [timedelta]

Timedelta refers to the difference between two timestamps, which is a measure of elapsed time. It may also specifically refer to the 'timedelta' type in Python.

Timedelta refers to the difference between two timestamps, which is a measure of elapsed time. It may also specifically refer to the timedelta type in Python.

In it is represented by Time.deltaTime which holds the elapsed time between frames and allows to coordinate animations and movement of gameObjects.

It is similar to the TimeSpan structure in .NET.

Other languages may have similar features as well.

See also the and tags.

1357 questions
-2
votes
1 answer

How to remove ambiguity from TimeDelta calculations?

I have a very simple set of code that I'm trying to generate a result off of a timedelta. currentdate = datetime.datetime.now() currentdate = currentdate.strftime("%m/%d/%Y") ##I need this first bit for another portion of my code, so it's a little…
-2
votes
1 answer

How to divide a timedelta between two days?

I have rows in a dataset which look like this: State StartDate EndDate Delta (hours) Day Correct 2022-07-12 19:00:00 2022-07-13 11:00:00 16 2022-07-12 I would like to separate the Delta for each day through Start and End dates, like…
-2
votes
1 answer

strg datatime to time delta

How to convert string datatime in to timedelta string = "%y -%m -%d 00:15:00" date_string = datetime.strftime(datetime.now(),string) date_final = datetime.fromtimestamp(mktime(date_string) typeerror = tuple or struct_time argument requried
-2
votes
2 answers

'job' object has no attribute 'd' . I tried to check everything but I am not able to it still has this error

Hello i am your assistant and i am gonna remind you periodically to have a break or do exercise or to drink water Traceback (most recent call last): File "C:\Users\lenovo\.spyder-py3\python_project_exercise7.py", line 51, in
Asrar
  • 21
  • 5
-2
votes
1 answer

Python datetime.timedelta not working with in arg

I'm trying to do a web scraper with selenium which will run as a AWS lambda function every week to book a time slot for me to go and play some tennis. My booking site is releasing new bookable time slots at midnight 2 weeks ahead of time. I have a…
-2
votes
1 answer

reduce 5 minutes from time using timedelta

Want to print time less than 5 mins after calculating time: now = datetime(2020,11,9,13,38,18) t0 = datetime.strptime((now - timedelta(minutes =(now.minute - (now.minute - (now.minute % 5))), seconds = now.second)).strftime("%Y-%m-%d…
Deoj
  • 71
  • 1
  • 5
-2
votes
2 answers

Get the business day before yesterday

Basically I am looking for some kind of method to calculate the business the day before yesterday since I have to run a t-2 query without any manual interference in the datetime variable: In a nutshell: 27.05.21 -> 25.05.21 Today's date is a…
RMNB
  • 13
  • 2
-2
votes
1 answer

Hello! I need help wich datetime

I wrote this code: chegada = input('Enter arrival time: "Hours: Minutes" ') saida = input('Inform the time of departure: "Hours: Minutes" ') fmt = '%H:%M' tdelta = datetime.strptime(saida, fmt) - datetime.strptime(chegada, fmt) if tdelta.days < 0: …
Pand
  • 25
  • 4
-2
votes
2 answers

Hours and time converting to a certain format

I have been trying to change the following format of time 8.25 (fractional hours) to 8.15 meaning 8:15. And 17.75 to 17.45 meaning 17:45. The problem is that I specifically need that format (timedelta) e.g 17.45 with a point . instead of :.
Dave Will
  • 95
  • 7
-2
votes
2 answers

Python: How do I check if time exceeds a specified time?

I'm trying to program a car park charges calculator. There are various rates provided: from 7 am to 10.30 pm - Rate $0.60 per 30 min Night charge 10.30 pm to 7 am - Flat fee of $5 If the parking duration spills over from day time rates to night time…
-2
votes
2 answers

Python timedelta class minutes

How to get timedelta's minutes and seconds(ex: 2:01)? Is there any formula for this? I've tried this, but it really didn't work well minutes = int(diff.seconds/60)
Delta888
  • 84
  • 6
-2
votes
2 answers

Add 90 days to a given date using Python 3 - I keep getting errors

I'm learning the Python 3 basics and this is a homework question, I thought it was simple but I'm definitely missing it. I have searched for solutions and can't seem to find anything that DOESN't start with today's date but just any given date.…
s11m00ne
  • 3
  • 4
-2
votes
5 answers

How to calculate average of seconds & milliseconds in Python?

My data is in the format of HH:MM:SS.milliseconds. How can I calculate average of such data in Python? I need average in form of miliseconds. I looked at several other similar postings but they do not answer my question. My data = 0:00:00.618000 …
A.S
  • 305
  • 1
  • 4
  • 20
-2
votes
1 answer

How do I convert timedelta to time in Python?

I did so: str_7 = str(waiting_time - timedelta(microseconds=waiting_time.microseconds)).split(":") col_7 = time(int(str_7[0]), int(str_7[1]), int(str_7[2])) Is this code correct?
Cícero Alves
  • 153
  • 1
  • 2
  • 6
-2
votes
2 answers

Make program sleep for X seconds in python

I am making an alarm clock program that will have to sleep (Not make noise) until 6:00AM. The problem I am having is that I cannot get the program to wait X seconds Pseudo Code: X = 6:00AM - CurrentTime time.sleep(X) Here is my code so…
user3532319
  • 17
  • 1
  • 1
  • 1
1 2 3
90
91