Questions tagged [python-relativedelta]

6 questions
1
vote
1 answer

Add/deduct month taking into account unequal days in calendar month

I am trying to come up with a way to create a list of dates n months back from given date dt. However, it seems to tricky based on what dt is. Below I am illustrating the dilemma through a few examples (esp. look at tricky case-3 below): from…
1
vote
2 answers

Question about dateutil.relativedelta - Why the ouput is always zero?

Why the output of this relativedelta attribute is also zero? The data file contains two date time strings, the purpose is to get the time difference between the two. # python3.6 time_diff.py 0 0 0 0 # cat data 06/21/2019 21:45:24 06/21/2020…
idiot one
  • 314
  • 1
  • 4
  • 11
1
vote
1 answer

Django Template Engine datetime comparison not working

I'm trying to build a small BBS-like app in Django, and I want to be able to restrict users from deleting posts more than 30 minutes old. However, I can't get the datetime comparison to work in the template engine. Here is a snippet of my…
0
votes
1 answer

How to use relativedelta to dynamically add dates to a list of dates in a dataframe

I am new to python and have a few questions regarding dates. Here is an example - I have a list of dates going from 01/01/2012 - 01/01/2025 with a monthly frequency. They also will change based on the data frame. Say one column of dates will have…
ARE
  • 99
  • 9
0
votes
1 answer

dateutil.relativedelta handles years incorrectly

There's something wrong with adding years: from datetime import datetime from dateutil.relativedelta import relativedelta if __name__ == '__main__': date = datetime.today().date() print(date) print(date + relativedelta(year=1)) ###…
Maxim Blumental
  • 763
  • 5
  • 26
0
votes
1 answer

python dynamic values to relativedelta function

Im trying to provide dynamic value to relativedelta function, i.e relativedelta(days=1) i would like to assign dynamic function value days, months, years to the function. Consider my situation as follows. I will get list dynamicaly as follows: Ex:…
DonOfDen
  • 3,968
  • 11
  • 62
  • 112