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
-1
votes
2 answers

Time difference in specific year in Python

I have a time range like this: runtime_start = datetime.date(2021,1,1) runtime_end = datetime.date(2022,3,1) current_year = datetime.date.today().year How can I calculate the number of month in the current_year? Some Examples: runtime_start =…
Jume
  • 63
  • 5
-1
votes
2 answers

How to calculate an employee elderness taking leap years into account in python

I'm trying to calculate employee seniority in my report. The contract specifies the date of hiring and the end date. The difference gives the number of years in seniority. I have this formula which calculates it for me normally except that by…
-1
votes
1 answer

I am facing a problem with python datetime objects, specifically the datetime.timedelta()

I am trying to find the difference in days as a number and not a datetime.timedelta() instance. I am using Django version 3.2 and fetching date values from a form on a template [Assume all the neccesary libaries are imported because its not an…
Chilusoft
  • 155
  • 1
  • 8
-1
votes
1 answer

Getting the error AttributeError: 'datetime.datetime' object has no attribute 'timedelta' when trying to add some datetimes

I want to get the total of times by doing this inner for loop...However it seems like I am doing something wrong here, because I am getting the error AttributeError: 'datetime.datetime' object has no attribute 'timedelta'... from datetime import…
lucasbbs
  • 349
  • 4
  • 14
-1
votes
1 answer

Python3 datetime module strange behavior

I came across a strange behavior of the datetime module of Python3: I calculate the difference between the dates "date" and "mon", and then add to the "date" first the resulting difference as it is, and then add to the "date" the resulting…
-1
votes
1 answer

Dealing with time format greater than 24 hours

I have data of experiments with time greater than 24 hours. For ex. [23:24:44, 25:10:44]. To operate duration of tests, I like to use Python, however I have a value error when I create datetime.time() with hours more than 23:59:.
joe kid
  • 33
  • 4
-1
votes
1 answer

Python3 check if int epochtime are less then X hours diff

I have two ints that represents epochtimes: x1 = 1597611600 x2 = 1597489203 I want to check if there is less then 72 hours between them. What is the best way to do so in Python3? Please notice that both are int.
Cranjis
  • 1,590
  • 8
  • 31
  • 64
-1
votes
1 answer

Getting dates in a year with a frequency of X days

An event occurs every X days in a year . The program must print the dates in which the event occurs in year Y as the output. The value of X and Y are passed as the input. The format of the date must be DD-MMM-YYYY. Input: X = 25 Y =…
THUNDER 07
  • 521
  • 5
  • 21
-1
votes
1 answer

In dataframe: how to pull minutes and seconds combinedly(mm:ss) from timedelta using python

i have already tried these but by this we can only get hour/minute/second but not both minute and second In[7]: df['B'] = df['A'].dt.components['hours'] df Out[7]: A B 0 02:00:00 2 1 01:00:00 1 from this timedelta format 0 0 days…
-1
votes
2 answers

Calculating the datetime of X amount of seconds before

I am trying to code a function where it calculates the date interval with x amount of seconds before the given_date. Each index of the previouse_dates is the time in seconds that comes before the given_date. import numpy as np given_date =…
tony selcuk
  • 709
  • 3
  • 11
-1
votes
2 answers

python convert timedelta to meaningful string such as "1 hours"

I want to convert a python timedelta object to an easy to read meaningful string for example: 0 1:0:0 -> 1 hours 0 0:5:0. -> 5 minutes 2 0:0:0. ->. 2 days any ideas how to do that? Thanks
Ido Barash
  • 4,856
  • 11
  • 41
  • 78
-1
votes
3 answers

Is there a way to redefine a "let" value when a certain condition becomes True?

Be gentle: I'm new to Javascript and curious about how I would go about running a for loop [or suggest a different loop that would be more fitting] that redefines a "let" value after a condition in the loop becomes True. When the last "else if"…
-1
votes
1 answer

Questions about Python3 timedate module

I have a quick question about a little snippet of code I've written and I have run into a little problem. I have created a program I want to run for exactly one hour, then exit it self. This does not seem to work as I saw it run for about three…
fzsty
  • 3
  • 1
-1
votes
2 answers

How can i get the average delivery time (stored as timedelta64[ns]) per day on Pandas?

So, i have the following data frame on pandas: I need to create another data frame with the average delivery time by day, by i'm having a hardtime with this task. So, as you can see, I have all the 365 days of 2018 and I need to calculate what was…
user8157645
-1
votes
1 answer

Converting MM:SS.ss string to a timedelta

I am trying to convert MM:SS.ss into a timedelta. So far, I have tried: df=pd.to_timedelta(df) it gave me TypeError: arg must be a string, timedelta, list, tuple, 1-d array, or Series. df = pd.to_datetime(df, format = "%MM:%SS:%ss") Example of…
CBegin
  • 29
  • 7