How can i find the day of week in python?¿ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How can i find the day of week in python?¿

Days like Monday,Tuesday.... How can i get it... Is it in-build in this app's compiler¿¿¿ In PYTHON

7th May 2020, 2:41 PM
Aayush-droid ★★★
Aayush-droid ★★★ - avatar
4 Answers
+ 6
import calendar yy = 2020 mm = 1 print(calendar.month(yy, mm)) Yes you can see this . Or try my code https://code.sololearn.com/cU9R4hgRAqZy/?ref=app
7th May 2020, 2:51 PM
Ayush Kumar
Ayush Kumar - avatar
+ 4
Handling of date and / or time information should be done with a datetime object. This object not only holds the values like day, month, year or hour, minute and so on, it also has a number of methods() and a great way to format the output of these data. If i have a date as such an object, weekday or what ever you need can be accessed. You can also calculate with date and time by adding or subtracting or calculating a difference between 2 dates can be obtained. Here are some basic tasks with datetime objects: import datetime as dt from datetime import datetime as dtdt sDate = '21,12,2019' dtDate = dtdt.strptime(sDate, "%d,%m,%Y") print(f"Day/Month/Year {dtdt.strftime(dtDate, '%d/%m/%Y')}") print(f"Year/Month/Day {dtdt.strftime(dtDate, '%Y/%m/%d')}") print(f"Day, Month, Day: {dtdt.strftime(dtDate, '%A, %d. %B %Y')}") print(dtDate.day) print() # alternative input of date time values dobj = dt.date(2019,12,21) print(f"Day, Month, Day: {dtdt.strftime(dobj, '%A, %d. %B %Y')}")
7th May 2020, 4:47 PM
Lothar
Lothar - avatar
7th May 2020, 2:47 PM
Abhay
Abhay - avatar
+ 2
https://stackoverflow.com/questions/9847213/how-do-i-get-the-day-of-week-given-a-date
7th May 2020, 2:55 PM
Oma Falk
Oma Falk - avatar