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”.

**Examples:**

Input :03 02 1997Output :MondayInput :31 01 2019Output :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 `datetime `

module.

The `weekday()`

function of date class in datetime module, returns an integer corresponding to the day of the week.

`# Python program to Find day of ` `# the week for a given date ` `import` `datetime ` `import` `calendar ` ` ` `def` `findDay(date): ` ` ` `born ` `=` `datetime.datetime.strptime(date, ` `'%d %m %Y'` `).weekday() ` ` ` `return` `(calendar.day_name[born]) ` ` ` `# Driver program ` `date ` `=` `'03 02 2019'` `print` `(findDay(date)) ` |

*chevron_right*

*filter_none*

**Output:**

Sunday

**Approach #2 :** Using `strftime()`

method

The `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.

`# Python program to Find day of ` `# the week for a given date ` `import` `datetime ` `from` `datetime ` `import` `date ` `import` `calendar ` ` ` `def` `findDay(date): ` ` ` `day, month, year ` `=` `(` `int` `(i) ` `for` `i ` `in` `date.split(` `' '` `)) ` ` ` `born ` `=` `datetime.date(year, month, day) ` ` ` `return` `born.strftime(` `"%A"` `) ` ` ` `# Driver program ` `date ` `=` `'03 02 2019'` `print` `(findDay(date)) ` |

*chevron_right*

*filter_none*

**Output:**

Sunday

**Approach #3 :** By finding day number

In this approach, we find the day number using `calender `

module and then find the correspoding week day.

`# Python program to Find day of ` `# the week for a given date ` `import` `calendar ` ` ` `def` `findDay(date): ` ` ` `day, month, year ` `=` `(` `int` `(i) ` `for` `i ` `in` `date.split(` `' '` `)) ` ` ` `dayNumber ` `=` `calendar.weekday(year, month, day) ` ` ` `days ` `=` `[` `"Monday"` `, ` `"Tuesday"` `, ` `"Wednesday"` `, ` `"Thursday"` `, ` ` ` `"Friday"` `, ` `"Saturday"` `, ` `"Sunday"` `] ` ` ` `return` `(days[dayNumber]) ` ` ` `# Driver program ` `date ` `=` `'03 02 2019'` `print` `(findDay(date)) ` |

*chevron_right*

*filter_none*

**Output:**

Sunday

## Recommended Posts:

- Find day of the week for a given date
- Tomohiko Sakamoto's Algorithm- Finding the day of the week
- Print day of week using Gregorian Calendar in java
- PyQt5 QCalendarWidget - Setting First Day of Week
- PyQt5 QCalendarWidget - Getting First Day of Week
- Extract week number from date in Pandas-Python
- C++ Program to print current Day, Date and Time
- Zeller's Congruence | Find the Day for a Date
- Get Day from date in Pandas - Python
- How to get Day, Month and Year from Date in Java
- Get the day from a date in Pandas
- Date after adding given number of days to the given date
- Python program to find the first day of given year
- How to print date starting from the given date for n number of days using Pandas?
- Python program to find birthdate on the same day you were born
- Python | Pandas PeriodIndex.week
- Python | Pandas DatetimeIndex.week
- Python | Pandas Period.week
- Python | Pandas Timestamp.week
- Python | Pandas Series.dt.week

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.