Linked Questions

629 votes
50 answers
830k views

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 ...
RailsSon's user avatar
  • 20.7k
-1 votes
2 answers
22k views

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)...
user3505844's user avatar
0 votes
2 answers
1k views

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,...
Anne's user avatar
  • 7,102
2 votes
3 answers
236 views

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 : ...
thomas.mac's user avatar
  • 1,256
0 votes
0 answers
40 views

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 = ...
jnord's user avatar
  • 93
117 votes
4 answers
200k views

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 ...
d0rmLife's user avatar
  • 4,320
15 votes
4 answers
23k views

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 ...
aairey's user avatar
  • 310
7 votes
5 answers
12k views

>>> 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 >>> ...
daydreamer's user avatar
  • 92.9k
7 votes
3 answers
7k views

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, ...
mortysporty's user avatar
  • 2,911
6 votes
2 answers
14k views

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 ...
Petar_Rudovic's user avatar
4 votes
5 answers
4k views

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 (...
Johnston's user avatar
  • 21.1k
1 vote
3 answers
2k views

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?
Nips's user avatar
  • 14k
1 vote
2 answers
7k views

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? ...
mina's user avatar
  • 13
0 votes
2 answers
1k views

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 ...
user032020's user avatar
0 votes
3 answers
635 views

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 ...
Ankit Tiwari's user avatar
  • 4,765

15 30 50 per page