Questions tagged [python-datetime]

Python's built-in datetime module provides classes for manipulating dates and times in both simple and complex ways.

Python's built-in datetime module provides classes for manipulating dates and times in both simple and complex ways.

View on Python docs - for Python 2 and Python 3.

1880 questions
0
votes
2 answers

Python get date from weekday

Let's say I have 11 Sessions for myself to complete. I haven't set dates for these sessions but rather just weekdays where one session would take place. Let's say when scheduling these sessions, I chose MON, TUE and WED. This means that after today,…
Rocky Cipher
  • 99
  • 10
0
votes
1 answer

problem with timezone and datetime libs in Django 2 and python 3

I'm a bit confused by the daylight savings handling. I have working on web notifier application in Django 2.0.6 framework and python 3.6. this application provide scheduling notification. for example users schedule message for some hours later or a…
Erfan
  • 485
  • 2
  • 6
  • 13
0
votes
0 answers

ValueError: unconverted data remains: 4

I am working with a column named "Time". This has hours in military time format, each row represents an hour. The goal is to convert each row into a datetime hours, however I keep running into this Value Error. I have tried using strip to no…
sus_zeus
  • 83
  • 9
0
votes
0 answers

ValueError during сonver str to datetime.date problem

I get the entry date in the format "2020-12-23", type - string. I have to compare it to the current date and run the if/else condition. code.py curent_date = datetime.date.today() csv_date = datetime.datetime.strptime(value,…
Jekson
  • 2,892
  • 8
  • 44
  • 79
0
votes
1 answer

last_scan_date and timestamp in Python

looking for an advise. Everyday I scan the SalesForce to find new opportunities and update the data accordingly. I am looking for a library or method that will store the last_scan_day and create a timestamp afterwards. So that the next day when the…
Chique_Code
  • 1,422
  • 3
  • 23
  • 49
0
votes
1 answer

how to iterate through for loop for every 3 hours and total of 7 days

from datetime import datetime as dt, date, timedelta import time startdate= dt.now() - timedelta(days = 7) enddate= dt.now() - timedelta(days = 1) HourList=[0,3,6,9,12,15,18,21] for hour in HourList: timeFrom =…
mr_gemini
  • 53
  • 4
0
votes
0 answers

How to convert datetime from string to utc aware version

I have a datetime, that originates from a string: myString = '20200505:1715' datetime.datetime.strptime(myString, "%Y%m%d:%H%M") # datetime.datetime(2020, 5, 5, 17, 15) This datetime happens in 'EST'. Following the advice, that one should operate…
0
votes
2 answers

Python Datetime Time Difference gives -999999999 in min when dif is small

In my small script I wanted to give script task time. In small time like under 1 min, I give min as -999999999. But there is no problem in others. Seconds and microseconds can be got and they are int type, though min My…
dose
  • 43
  • 1
  • 3
0
votes
1 answer

Automated monthly report Python-Jira

A small request. I'm a junior in Python and Jira but I want to learn :) I have a code from a colleague that left the company for automated report of number of incidents in last 12 months! What I want to have is number of incidents automated monthly…
0
votes
2 answers

How to add minutes to a datetime range comparison?

How can I alter the below to account for minutes as well as our in datetime range? For example the below works fine. from datetime import datetime if (datetime.now().hour>=14) and (datetime.now().hour<=16): print ('afternoon' ) else: …
E J
  • 81
  • 1
  • 1
  • 6
0
votes
0 answers

Ordering by day of week - Django

I want to create a weekly calendar according to created schedules by admin. Days of week should be displayed horizontally, and each of schedules under according day of week, vertically. Now my code works like in this picture. But I want to display,…
0
votes
2 answers

Python Identifying most recent time(datetime) from a list?

I have two lists time_list with datetime and name_list with names mapped to each other respectively. time_list = [datetime.datetime(2020, 3, 28, 18, 49, 36, tzinfo=tzutc()), datetime.datetime(2020, 3, 28, 18, 54, 53, tzinfo=tzutc()), …
user11509999
0
votes
2 answers

How to use if function in pandas

I have one dataframe I want to add a column in this datafram as 'VAR', the values in this new column should be updated with "L" if the difference between 'END' and 'START' column is greater than or equal to 365, otherwise it should be "S" Final…
0
votes
1 answer

Python how to customize datetime format using strftime

file.write("%s," %(fake.date_between(start_date=datetime(2001,1,1),end_date= datetime(2015,1,1))).strftime("%m / %Y").replace('0 ',' ')) While writing data into csv file I want the output as monthnumber/year ex 8/2019 but this code returns Aug-2019…
Nishanthi
  • 1
  • 2
0
votes
2 answers

Python - how to convert string with '+' sign in minutes to datetime?

How would I convert this string 2019-07-11T00:00+02:00 to datetime? Using this %Y-%m-%dT%H:%M:%S as format code in strptime returns an error. I assume the +02 is causing this as without it, it will convert to a datetime properly. debut =…
mhmrhiman
  • 17
  • 5