Write a Python program to find the day of the week for any particular date in the past or future. Let the input be in the format “dd mm yyyy”.
Input : 03 02 1997 Output : Monday Input : 31 01 2019 Output : Thursday
The already discussed approach to find the day of the week for a given date is the Naive approach. Now, let’s discuss the pythonic approaches.
Approach #1 : Using
weekday() provided by
weekday() function of date class in datetime module, returns an integer corresponding to the day of the week.
Approach #2 : Using
strftime() method takes one or more format codes as an argument and returns a formatted string based on it. Here we will pass the directive “%A” in the method which provides Full weekday name for the given date.
Approach #3 : By finding day number
In this approach, we find the day number using
calender module and then find the correspoding week day.
- Find day of the week for a given date
- Python | Find yesterday's, today's and tomorrow's date
- Python | Pandas DatetimeIndex.week
- Python | Pandas Timestamp.week
- Python | Pandas Period.week
- Python | Pandas PeriodIndex.week
- Python | Pandas Series.dt.week
- Python Program for Program to find area of a circle
- Python Program for Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Program to check if a date is valid or not
- C++ Program to print current Day, Date and Time
- Program to Convert Milliseconds to a Date Format in Java
- Python Program to find whether a no is power of two
- Python program to find all possible pairs with given sum
- Python Program to find sum of array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.