Linked Questions
20 questions linked to/from How to increment datetime by custom months in python without using library
629
votes
50
answers
830k
views
How do I calculate the date six months from the current date using the datetime Python module?
I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?
The reason I want to generate a date 6 ...
-1
votes
2
answers
22k
views
Iterating over date in python [duplicate]
This is my code:
MYDATE = []
start_date = "2011-01-01"
stop_date = "2013-05-01"
start = start_date.strftime("%Y-%m-%d")
stop = stop_date.strftime("%Y-%m-%d")
for r in .......:
MYDATE.append((r,r)...
0
votes
2
answers
1k
views
python datetime: How to get next period (using aliases such as 'D', 'M') [duplicate]
Is there any way to get from a date to the next period? I.e. I am looking for a funaction next that takes
now = datetime.datetime(2013, 11, 15, 0, 0)
to
next(now, 'D') = datetime.datetime(2013, 11,...
2
votes
3
answers
236
views
Adding two strings together in dt.datetime [duplicate]
I have :
excessmove_start = '2015-1-6'
I want to have a new variable called excess_graph which is always 3 months ahead of excessmove_start.
So, for this example, my expected output would be :
...
0
votes
0
answers
40
views
Datetime ValueError: month must be in 1..12 [duplicate]
I am working with datetime to get the dates of the next two months using the following code
a = datetime.datetime.today()
#logic to get next two month numbers
try:
nextmonthdate = ...
117
votes
4
answers
200k
views
Is there a simple way to increment a datetime object one month in Python? [duplicate]
So I am trying to find a way to increment a datetime object by one month. However, it seems this is not so simple, according to this question.
I was hoping for something like:
import datetime as ...
15
votes
4
answers
23k
views
How to use dateutil.relativedelta in Python 3.x?
Hello I am trying to use relativedelta from the dateutil module.
I want to do what is mentioned here, add some months to a given datetime object.
But I'm trying to use Python 3 for this and I am ...
7
votes
5
answers
12k
views
Python : How to add month to December 2012 and get January 2013?
>>> start_date = date(1983, 11, 23)
>>> start_date.replace(month=start_date.month+1)
datetime.date(1983, 12, 23)
This works until the month is <=11, as soon as I do
>>> ...
7
votes
3
answers
7k
views
Pandas create date range at certain dates
I want to create a list (or array or whathever) of a given number of dates at monthly intervals.
Basically what I want is this
>>>some_function(start_date=date(2005, 5, 14), periods=4, ...
6
votes
2
answers
14k
views
How do I add a month to my date object in datetime? [duplicate]
I need to create a day variable which will store the current date, and I need another variable which will store the deadline(day + 1 month), but I seem to be doing something wrong.
import datetime
...
4
votes
5
answers
4k
views
How do I find the nth day of the next month in Python?
I am trying to get the date delta by subtracting today's date from the nth day of the next month.
delta = nth_of_next_month - todays_date
print delta.days
How do you get the date object for the 1st (...
1
vote
3
answers
2k
views
How to get date range at now to end of the month?
I use datetime, i have:
delta = ((datetime.date.today() + datetime.timedelta(days=1)) - datetime.timedelta(???)).isoformat()
I need replace ??? with day to end of the month.
How to do it?
1
vote
2
answers
7k
views
how to set date variables in python in different formats?
My code starts off by setting these 3 variables
var1 = 'Sep20'
var2 = '2020 09'
var3 = '2020-10-01'
How do I code such that var2 and var3 are functions of var1, so that I only have to set 1 variable? ...
0
votes
2
answers
1k
views
How to get 1st calendar day of the current and next month based on a current date variable
I have a date variable calls today_date as below. I need to get the 1st calendar day of the current and next month.
In my case, today_date is 4/17/2021, I need to create two more variables calls ...
0
votes
3
answers
635
views
How can I extend month in Django
I am trying to add extra month in my expiry_date field in Django, I've done like this
import datetime
now = datetime.datetime.now()
year = now.year
day = now.day
hour = now.hour
minute = now.minute
...