weekday

Trying to create a list of random times within specific date/time conditions

Trying to create a list of random times within specific date/time conditions Question: I am trying to modify this GitHub code for my own purposes in the title: import random from datetime import datetime, timedelta min_year=1900 max_year=datetime.now().year start = datetime(min_year, 1, 1, 00, 00, 00) years = max_year – min_year+1 end = start + timedelta(days=365 …

Total answers: 2

How do I get the next X day of the week

How do I get the next X day of the week Question: So I have this function that retrieve the date from given days from today: def get_date_from_today(d): tomorrow = datetime.date.today() + datetime.timedelta(days=d) return tomorrow.strftime("%Y/%m/%d") How do I get for example the date of the next Thursday ? If today if Thursday I want to …

Total answers: 2

Difference between today,week start

Difference between today,week start Question: How to get the difference between datetime.datetime.utcnow(), and the start of week? I want start of week of "date=17,month=12,year=2022,hour=x,minute=y,second=z" to be: "date=12,month=12,year=2022,hour=0,minute=0,second=0", where x,y,z are variables,while they have to be converted to 0,0,0 only. I tried the following code: from datetime import datetime as dt, timezone as tz, timedelta as …

Total answers: 1

How to get day of the week based on inputed date(Python)

How to get day of the week based on inputed date(Python) Question: So i wanted the user to enter date and based on that day to get named day of the week, for example today’s date is 2022.11.10, so wanted answer would be Thursday. I know this is wrong, can anybody help? import datetime def …

Total answers: 2

How to convert a number to its correlating day of the week?

How to convert a number to its correlating day of the week? Question: How do I convert a number to its correlating day of the week? For example: def string(hour_of_day, day_of_week, date) : print(f'{day_of_week} {date} at hour {hour_of_day}’) how can I re-write the ‘day_of_week’ part in print so that when I use the function: string(12, …

Total answers: 3

How do I get the day of week given a date?

How do I get the day of week given a date? Question: I want to find out the following: given a date (datetime object), what is the corresponding day of the week? For instance, Sunday is the first day, Monday: second day.. and so on And then if the input is something like today’s date. …

Total answers: 30

Return a list of weekdays, starting with given weekday

Return a list of weekdays, starting with given weekday Question: My task is to define a function weekdays(weekday) that returns a list of weekdays, starting with the given weekday. It should work like this: >>> weekdays(‘Wednesday’) [‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’, ‘Monday’, ‘Tuesday’] So far I’ve come up with this one: def weekdays(weekday): days = …

Total answers: 12